Can't disconnect signal if connected using @receiver tag
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.6|
|Severity:||Normal||Keywords:||@receiver signal disconnect|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I got signal handler function hooked to pre_save signal using @receiver.
When I tried to disconnect that signal handler temporarily in TestCase, I couldn't achieve that. The lookup key generated in dispatcher (lookup_key = (_make_id(receiver), _make_id(sender))) in order to match function which should be disconnected has other value than it should have so the function can't be found in self.receivers and handler doesn't get disconnected.
That's probably because in self.receivers there is a lookup key generated based on "wrapper" function which had been taken to generate that lookup when registering handler, not the original one, that's why importing original function and passing it to .disconnect() doesn't work.
When signal connected without using @receiver but using pre_save.connect it works as expected.
Change History (4)
comment:1 Changed 2 years ago by
|Patch needs improvement:||unset|
|Summary:||Can't disconnect signal if connected using @reeiver tag → Can't disconnect signal if connected using @receiver tag|