MCPcopy Index your code
hub / github.com/borgbackup/borg / signal_handler

Function signal_handler

src/borg/helpers/process.py:168–187  ·  view source on GitHub ↗

When entering the context, set up signal handler for signal . When leaving the context, restore the original signal handler. can be either a str (the name of a signal.SIGXXX attribute; it will not crash if the attribute name does not exist, as some names are pl

(sig, handler)

Source from the content-addressed store, hash-verified

166
167@contextlib.contextmanager
168def signal_handler(sig, handler):
169 """
170 When entering the context, set up signal handler <handler> for signal <sig>.
171 When leaving the context, restore the original signal handler.
172
173 <sig> can be either a str (the name of a signal.SIGXXX attribute; it
174 will not crash if the attribute name does not exist, as some names are platform
175 specific) or an int (a signal number).
176
177 <handler> is any handler value accepted by signal.signal(sig, handler).
178 """
179 if isinstance(sig, str):
180 sig = getattr(signal, sig, None)
181 if sig is not None:
182 orig_handler = signal.signal(sig, handler)
183 try:
184 yield
185 finally:
186 if sig is not None:
187 signal.signal(sig, orig_handler)
188
189
190def raising_signal_handler(exc_cls):

Callers 6

mountMethod · 0.85
mountMethod · 0.85
daemonizingFunction · 0.85
__init__Method · 0.85
sig_info_handlerFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected