Can't disconnect signal if connected using @receiver tag
|Reported by:||michalsicker@…||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 (3)
comment:1 Changed 9 months ago by timo
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Summary changed from Can't disconnect signal if connected using @reeiver tag to Can't disconnect signal if connected using @receiver tag
comment:2 follow-up: ↓ 3 Changed 9 months ago by bmispelon
- Resolution set to worksforme
- Status changed from new to closed