Created
September 26, 2013 14:56
-
-
Save piksel/6715377 to your computer and use it in GitHub Desktop.
Code to restart the python script if it gets an OOM exception. Yes, this is the wrong way to handle memory leaks, but unfortunately they sometimes occur in libraries out of your control.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
main() | |
except MemoryError, e: | |
print("Out of memory! Restarting proces...") | |
os.execl(sys.executable, *([sys.executable]+sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment