-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Milestone
Description
Simply put, I need to perform some cleanup under the assumption that a user may decide to CTRL + C to shutdown the IPython Notebooks at any time. The following script demonstrates the problem:
import atexit
from subprocess import Popen
def myFunc():
Popen(["mkdir","dummyDir"]).communicate()
atexit.register(myFunc)
while True:
pass
If I run this code without the while True block and then CTRL + C twice, I see that the directory dummyDir has been created in the notebook directory, whereas if I run this code with the while True block, the directory is not created. Is there a way that I can guarantee that the cleanup will be performed? I have also tried using try/finally and I encounter the same problem:
try:
while(True):
pass
finally:
myFunc()
The output of import IPython; print(IPython.sys_info()) is
{'commit_hash': u'f534027',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/homes/breese/testroot/share/parameter_server/iPythonEnv/Python/lib/python2.7/site-packages/IPython',
'ipython_version': '4.0.0',
'os_name': 'posix',
'platform': 'Linux-2.6.32-431.23.3.el6.YAHOO.20140804.x86_64-x86_64-with-redhat-6.5-Santiago',
'sys_executable': '/homes/breese/testroot/share/parameter_server/iPythonEnv/Python/bin/python',
'sys_platform': 'linux2',
'sys_version': '2.7.10 (default, Nov 20 2015, 23:24:22) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]'}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels