How can I stop a python process in such a way that any active context managers will gracefully call their __exit__ function before closing?
I use context managers (__ent
I found a workaround on the PyCharm bug tracker:
https://youtrack.jetbrains.com/issue/PY-17252
If you use Numpy or Scipy, you will also need to add the following environment variable:
os.environ['FOR_DISABLE_CONSOLE_CTRL_HANDLER'] = "1"
Restart Pycharm
Now when I run my test with this applied (on Windows!) I get the following output:
Init called.
enter called
Exit called
Traceback (most recent call last):
File "C:/Users/.../.PyCharmCE2017.1/config/scratches/scratch_3.py", line 20, in <module>
time.sleep(100)
KeyboardInterrupt
Process finished with exit code 1