#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.

-- 
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/064.577394246be4744696eb363fee6e8b35%40djangoproject.com.

Reply via email to