Re: [Django] #32054: Signal disconnect not working with multiple decorators

81 views
Skip to first unread message

Django

unread,
Sep 29, 2020, 2:40:31 AM9/29/20
to django-...@googlegroups.com
#32054: Signal disconnect not working with multiple decorators
-------------------------------------+-------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: signals | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Ron:

Old description:

> Here's my setup:
>

>
> {{{
> class MyModel(models.Model):
> pass
>
> @receiver(post_save, sender=MyModel)
> @receiver(post_delete, sender=MyModel)
> def process_stuff(sender, instance, **kwargs):
> # to some magic
> pass
> }}}
>
> When I want to disconnect the post_save signal like this:
>
> {{{
> from django.db.models import signals
> signals.post_save.disconnect(
> receiver=process_stuff,
> sender=MyModel,
> }}}
>
> ... it does not work.
>
> If I comment out the second decorator with `post_delete`, it works.
>
> If I split this up and use two different functions, it works as well.
>
> I posted at StackOverflow (https://stackoverflow.com/q/64102708/1331671)
> and in some django groups, but no replies yet.
>
> Seems like a bug to me :(

New description:

Here's my setup on django 3.0.10:


{{{
class MyModel(models.Model):
pass

@receiver(post_save, sender=MyModel)
@receiver(post_delete, sender=MyModel)
def process_stuff(sender, instance, **kwargs):
# to some magic
pass
}}}

When I want to disconnect the post_save signal like this:

{{{
from django.db.models import signals
signals.post_save.disconnect(
receiver=process_stuff,
sender=MyModel,
}}}

... it does not work.

If I comment out the second decorator with `post_delete`, it works.

If I split this up and use two different functions, it works as well.

I posted at StackOverflow (https://stackoverflow.com/q/64102708/1331671)
and in some django groups, but no replies yet.

Seems like a bug to me :(

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32054#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 29, 2020, 4:50:39 AM9/29/20
to django-...@googlegroups.com
#32054: Signal disconnect not working with multiple decorators
-------------------------------------+-------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: signals | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ron):

Sure, I'll update my question accordingly. Thanks for your time so far!

--
Ticket URL: <https://code.djangoproject.com/ticket/32054#comment:5>

Reply all
Reply to author
Forward
0 new messages