MCPcopy Create free account
hub / github.com/celery/celery / blockdetection

Function blockdetection

celery/utils/debug.py:42–60  ·  view source on GitHub ↗

Context that raises an exception if process is blocking. Uses ``SIGALRM`` to detect blocking functions.

(timeout)

Source from the content-addressed store, hash-verified

40
41@contextmanager
42def blockdetection(timeout):
43 """Context that raises an exception if process is blocking.
44
45 Uses ``SIGALRM`` to detect blocking functions.
46 """
47 if not timeout:
48 yield
49 else:
50 old_handler = signals['ALRM']
51 old_handler = None if old_handler == _on_blocking else old_handler
52
53 signals['ALRM'] = _on_blocking
54
55 try:
56 yield signals.arm_alarm(timeout)
57 finally:
58 if old_handler:
59 signals['ALRM'] = old_handler
60 signals.reset_alarm()
61
62
63def sample_mem():

Callers

nothing calls this directly

Calls 2

arm_alarmMethod · 0.80
reset_alarmMethod · 0.80

Tested by

no test coverage detected