diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py
index d26433a..3993c47 100644
a
|
b
|
|
1 | | import weakref |
| 1 | import sys |
2 | 2 | import threading |
| 3 | import weakref |
| 4 | |
3 | 5 | |
4 | 6 | from django.dispatch import saferef |
5 | 7 | from django.utils.six.moves import xrange |
… |
… |
class Signal(object):
|
105 | 107 | assert argspec[2] is not None, \ |
106 | 108 | "Signal receivers must accept keyword arguments (**kwargs)." |
107 | 109 | |
| 110 | receiver_id = _make_id(receiver) |
108 | 111 | if dispatch_uid: |
109 | 112 | lookup_key = (dispatch_uid, _make_id(sender)) |
110 | 113 | else: |
111 | | lookup_key = (_make_id(receiver), _make_id(sender)) |
| 114 | lookup_key = (receiver_id, _make_id(sender)) |
112 | 115 | |
113 | 116 | if weak: |
114 | | receiver = saferef.safeRef(receiver, onDelete=self._remove_receiver) |
| 117 | on_delete = self._remove_receiver |
| 118 | if not sys.version_info < (3, 4): |
| 119 | weakref.finalize(receiver, on_delete, receiver_id=receiver_id) |
| 120 | on_delete = None |
| 121 | receiver = saferef.safeRef(receiver, onDelete=on_delete) |
115 | 122 | |
116 | 123 | with self.lock: |
117 | 124 | for r_key, _ in self.receivers: |
… |
… |
class Signal(object):
|
262 | 269 | non_weak_receivers.append(receiver) |
263 | 270 | return non_weak_receivers |
264 | 271 | |
265 | | def _remove_receiver(self, receiver): |
| 272 | def _remove_receiver(self, receiver=None, receiver_id=None): |
266 | 273 | """ |
267 | 274 | Remove dead receivers from connections. |
268 | 275 | """ |
269 | | |
| 276 | receiver_id = _make_id(receiver) if receiver is not None else receiver_id |
270 | 277 | with self.lock: |
271 | 278 | to_remove = [] |
272 | 279 | for key, connected_receiver in self.receivers: |
273 | | if connected_receiver == receiver: |
| 280 | if _make_id(connected_receiver) == receiver_id: |
274 | 281 | to_remove.append(key) |
275 | 282 | for key in to_remove: |
276 | 283 | last_idx = len(self.receivers) - 1 |