Debian Codegraph @

pypy/module/__pypy__/app_signal.py

raw symbols SCIP
1 from .thread import _signals_enter, _signals_exit
2 # ^^ relative import of __pypy__.thread. Note that some tests depend on
3 # this (test_enable_signals in test_signal.py) to work properly,
4 # otherwise they get caught in some deadlock waiting for the import
5 # lock...
6
7
8 class SignalsEnabled(object):
9 '''A context manager to use in non-main threads:
10 enables receiving signals in a "with" statement. More precisely, if a
11 signal is received by the process, then the signal handler might be
12 called either in the main thread (as usual) or within another thread
13 that is within a "with signals_enabled:". This other thread should be
14 ready to handle unexpected exceptions that the signal handler might
15 raise --- notably KeyboardInterrupt.'''
16 __enter__ = _signals_enter
17 __exit__ = _signals_exit
18
19 signals_enabled = SignalsEnabled()