Skip to content

Instantly share code, notes, and snippets.

@saghul
Created January 9, 2011 22:39
Show Gist options
  • Save saghul/772101 to your computer and use it in GitHub Desktop.
Save saghul/772101 to your computer and use it in GitHub Desktop.
Example on using resourcelimit module to enable core dumps from Python
from optparse import OptionParser
from time import sleep
def do_something():
while True:
print "I'm doing something"
sleep(5)
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('--dump-core', action='store_true', dest='dump_core', default=False)
options, args = parser.parse_args()
if options.dump_core:
print "Core dump enabled"
import resource
resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
do_something()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment