MCPcopy
hub / github.com/celery/celery / _connect_signal

Method _connect_signal

celery/utils/dispatch/signal.py:147–180  ·  view source on GitHub ↗
(fun)

Source from the content-addressed store, hash-verified

145 retry=False):
146
147 def _connect_signal(fun):
148
149 options = {'dispatch_uid': dispatch_uid,
150 'weak': weak}
151
152 def _retry_receiver(retry_fun):
153
154 def _try_receiver_over_time(*args, **kwargs):
155 def on_error(exc, intervals, retries):
156 interval = next(intervals)
157 err_msg = RECEIVER_RETRY_ERROR % \
158 {'receiver': retry_fun,
159 'when': humanize_seconds(interval, 'in', ' ')}
160 logger.error(err_msg)
161 return interval
162
163 return retry_over_time(retry_fun, Exception, args,
164 kwargs, on_error)
165
166 return _try_receiver_over_time
167
168 if retry:
169 options['weak'] = False
170 if not dispatch_uid:
171 # if there's no dispatch_uid then we need to set the
172 # dispatch uid to the original func id so we can look
173 # it up later with the original func id
174 options['dispatch_uid'] = _make_id(fun)
175 fun = _retry_receiver(fun)
176 fun._dispatch_uid = options['dispatch_uid']
177
178 self._connect_signal(fun, sender, options['weak'],
179 options['dispatch_uid'])
180 return fun
181
182 return _connect_signal
183

Callers

nothing calls this directly

Calls 8

_clear_dead_receiversMethod · 0.95
fun_accepts_kwargsFunction · 0.90
_make_idFunction · 0.85
_make_lookup_keyFunction · 0.85
__then__Method · 0.80
finalizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected