MCPcopy
hub / github.com/celery/celery / Trap

Class Trap

celery/contrib/testing/app.py:23–36  ·  view source on GitHub ↗

Trap that pretends to be an app but raises an exception instead. This to protect from code that does not properly pass app instances, then falls back to the current_app.

Source from the content-addressed store, hash-verified

21
22
23class Trap:
24 """Trap that pretends to be an app but raises an exception instead.
25
26 This to protect from code that does not properly pass app instances,
27 then falls back to the current_app.
28 """
29
30 def __getattr__(self, name):
31 # Workaround to allow unittest.mock to patch this object
32 # in Python 3.8 and above.
33 if name == '_is_coroutine' or name == '__func__':
34 return None
35 print(name)
36 raise RuntimeError('Test depends on current_app')
37
38
39class UnitLogging(symbol_by_name(Celery.log_cls)):

Callers 2

setup_sessionFunction · 0.90
set_trapFunction · 0.85

Calls

no outgoing calls

Tested by 1

setup_sessionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…