ATLAS Offline Software
Loading...
Searching...
No Matches
Tools
PyJobTransforms
python
trfSignal.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
10
11
import
signal
12
13
import
logging
14
msg = logging.getLogger(__name__)
15
16
_savedSignalHandlerDict = {}
17
18
# N.B. Do not catch SIGINT (^C). This is delt with more cleanly via
19
# the stdTrfExceptionHandler wrapper which handles the KeyboardInterrupt exception.
20
# Also, don't intercept SIGTERM as this is used by the multiprocessing module to
21
# terminate child proceses
22
_defaultSignalList = [
'SIGABRT'
,
'SIGFPE'
,
'SIGBUS'
,
'SIGHUP'
,
'SIGILL'
,
'SIGIO'
,
'SIGPIPE'
,
'SIGQUIT'
,
'SIGSEGV'
,
'SIGSYS'
,
'SIGXCPU'
,
'SIGXFSZ'
]
23
24
28
def
setTrfSignalHandlers
(handler):
29
for
s
in
_defaultSignalList:
30
try
:
31
msg.debug(
"Setting signalhandler for %s to %s"
, s, handler)
32
_savedSignalHandlerDict[s] = signal.signal(getattr(signal, s), handler)
33
except
Exception
as
e:
34
msg.error(
"Unable to attach custom signal handler to %s: %s"
, s, e)
35
continue
36
37
40
def
resetTrfSignalHandlers
():
41
for
s
in
_defaultSignalList:
42
try
:
43
signal.signal(getattr(signal, s), _savedSignalHandlerDict.get(s, signal.SIG_DFL))
44
except
Exception
as
e:
45
msg.error(
"Unable to attach custom signal handler to %s: %s"
, s, e)
46
continue
python.trfSignal.setTrfSignalHandlers
setTrfSignalHandlers(handler)
Install common handler for various signals.
Definition
trfSignal.py:28
python.trfSignal.resetTrfSignalHandlers
resetTrfSignalHandlers()
Restore signal handlers to the default ones.
Definition
trfSignal.py:40
Generated on
for ATLAS Offline Software by
1.14.0