MCPcopy
hub / github.com/django/django / send

Method send

django/dispatch/dispatcher.py:219–263  ·  view source on GitHub ↗

Send signal from sender to all connected receivers. If any receiver raises an error, the error propagates back through send, terminating the dispatch loop. So it's possible that all receivers won't be called if an error is raised. If any receivers are async

(self, sender, **named)

Source from the content-addressed store, hash-verified

217 return bool(sync_receivers) or bool(async_receivers)
218
219 def send(self, sender, **named):
220 """
221 Send signal from sender to all connected receivers.
222
223 If any receiver raises an error, the error propagates back through
224 send, terminating the dispatch loop. So it's possible that all
225 receivers won't be called if an error is raised.
226
227 If any receivers are asynchronous, they are called after all the
228 synchronous receivers via a single call to async_to_sync(). They are
229 also executed concurrently with asyncio.TaskGroup().
230
231 Arguments:
232
233 sender
234 The sender of the signal. Either a specific object or None.
235
236 named
237 Named arguments which will be passed to receivers.
238
239 Return a list of tuple pairs [(receiver, response), ... ].
240 """
241 if (
242 not self.receivers
243 or self.sender_receivers_cache.get(sender) is NO_RECEIVERS
244 ):
245 return []
246 responses = []
247 sync_receivers, async_receivers = self._live_receivers(sender)
248 for receiver in sync_receivers:
249 response = receiver(signal=self, sender=sender, **named)
250 responses.append((receiver, response))
251 if async_receivers:
252
253 async def asend():
254 async_responses = await _run_parallel(
255 *(
256 receiver(signal=self, sender=sender, **named)
257 for receiver in async_receivers
258 )
259 )
260 return zip(async_receivers, async_responses)
261
262 responses.extend(async_to_sync(asend)())
263 return responses
264
265 async def asend(self, sender, **named):
266 """

Callers 15

test_sendMethod · 0.95
runMethod · 0.45
notify_file_changedMethod · 0.45
closeMethod · 0.45
__call__Method · 0.45
instrumented_test_renderFunction · 0.45
enableMethod · 0.45
_pre_setupMethod · 0.45

Calls 5

_live_receiversMethod · 0.95
receiverFunction · 0.85
extendMethod · 0.80
getMethod · 0.45
appendMethod · 0.45