Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12032 closed (invalid)

Signals receivers not called when the receiver is a closure

Reported by: alek@… Owned by:
Component: Core (Other) Version: master
Severity: Keywords: signals
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

>>> from django.db import models
>>> def x():
...     def y(sender, **kwargs):
...         print 'y called'
...     models.signals.post_init.connect(y, sender = User)
...
>>> x()
>>>
>>> def z(sender, **kwargs):
...     print 'z called'
...
>>> models.signals.post_init.connect(z, sender = User)
>>>
>>> a = User()
z called
>>>

Expected result:

>>> a = User()
y called
z called
>>>

Change History (4)

comment:1 Changed 7 years ago by anonymous

Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to anonymous
Patch needs improvement: unset
Status: newassigned

comment:2 Changed 7 years ago by anonymous

Owner: anonymous deleted
Status: assignednew

comment:3 Changed 7 years ago by dc

Resolution: invalid
Status: newclosed

That's not a bug, that's a feature.

def connect(self, receiver, sender=None, weak=True, dispatch_uid=None)

weak

Whether to use weak references to the receiver By default, the
module will attempt to use weak references to the receiver
objects. If this parameter is false, then strong references will
be used.

comment:4 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top