def safe_call(function, *args, **kwargs):
"""
If we're not in the main process, sets the default signal handler
(`signal.SIG_DFL`) for the ``SIGINT`` signal before calling *function*
using the given *args* and *kwargs*. Otherwise *function* will just be
called and returned normally.
The point being to prevent loads of unnecessary tracebacks from being
printed to stdout when the user executes a :kbd:`Ctrl-C` on a running
gateone.py process.
.. note::
This function is only meant to be used to wrap calls made inside of
`MultiprocessRunner` instances.
"""
if os.getpid() != PID:
signal.signal(signal.SIGINT, signal.SIG_DFL)
return function(*args, **kwargs)
评论列表
文章目录