From aee9db9b3e620aa405dae1570d40b79da029ed78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Sun, 21 Nov 2010 17:34:21 +0000 Subject: [PATCH] Preventing problems possibly introduced by r14662 acquire a lock before entering a try block that ends with the lock's release. Thanks for the catch Alex. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14668 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/dispatch/dispatcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py index 9beb309ac1..ed9da57f27 100644 --- a/django/dispatch/dispatcher.py +++ b/django/dispatch/dispatcher.py @@ -99,8 +99,8 @@ class Signal(object): if weak: receiver = saferef.safeRef(receiver, onDelete=self._remove_receiver) + self.lock.acquire() try: - self.lock.acquire() for r_key, _ in self.receivers: if r_key == lookup_key: break @@ -136,8 +136,8 @@ class Signal(object): else: lookup_key = (_make_id(receiver), _make_id(sender)) + self.lock.acquire() try: - self.lock.acquire() for index in xrange(len(self.receivers)): (r_key, _) = self.receivers[index] if r_key == lookup_key: @@ -237,8 +237,8 @@ class Signal(object): Remove dead receivers from connections. """ + self.lock.acquire() try: - self.lock.acquire() to_remove = [] for key, connected_receiver in self.receivers: if connected_receiver == receiver: