#35801: Signals are dispatched to receivers associated with dead senders
------------------------------+------------------------------------
Reporter: bobince | Owner: (none)
Type: Bug | Status: new
Component: Core (Other) | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Natalia Bidart):
* cc: Simon Charette (added)
* resolution: needsinfo =>
* stage: Unreviewed => Accepted
* status: closed => new
Comment:
Replying to [comment:2 bobince]:
> > I don't think it's correct to clear receivers_called = [] like that
inside the loop
>
> It should be fine as long as the loop is in the same scope as the
definition of receivers_called. But yes, it might be clearer to reset the
list without rebinding it by doing `del receivers_called[:]`.
Right, I would suggest `receivers_called.clear()`
> > Sadly, this does not fail for me at any iteration
>
> That's because the new example stores a reference to `sender` in
`signal_calls`, which prevents the sender being destroyed and its id re-
used.
>
> If you store `id(sender)` or `str(sender)` instead you'll get the error
again.
Great catch, that makes perfect sense. I tweaked my script and was able to
confirm your report. I'll accept this ticket on that basis, I couldn't
find a previous report about this.
Would you like to prepare a patch?
(Adding Simon as cc since he might have some good ideas for a robust fix.)
--
Ticket URL: <https://code.djangoproject.com/ticket/35801#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107019252cedbd5-240ea609-2f34-49eb-8ea5-9af195759b7e-000000%40eu-central-1.amazonses.com.