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

Function _temporary_command

t/unit/app/test_preload_cli.py:65–78  ·  view source on GitHub ↗

Register a Click command for one CLI invoke, then put the group back.

(command)

Source from the content-addressed store, hash-verified

63
64@contextlib.contextmanager
65def _temporary_command(command):
66 """Register a Click command for one CLI invoke, then put the group back."""
67 original_callbacks = {
68 name: existing.callback for name, existing in celery.commands.items()
69 }
70 celery.add_command(command)
71 try:
72 yield
73 finally:
74 for name, callback in original_callbacks.items():
75 existing = celery.commands.get(name)
76 if existing is not None:
77 existing.callback = callback
78 celery.commands.pop(command.name, None)
79
80
81def _on_preload(received):

Calls 3

itemsMethod · 0.45
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected