This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dougz
Recipients dougz, pitrou
Date 2014-08-11.23:47:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1407800831.15.0.236937632355.issue22185@psf.upfronthosting.co.za>
In-reply-to
Content
Condition.wait() modifies self._waiters without holding the lock (when a wait with timeout times out without the condition being notified).

If this happens to occur in between construction of the _islice and _deque objects in Condition.notify():

    def notify(self, n=1):
        [...]
        all_waiters = self._waiters
        waiters_to_notify = _deque(_islice(all_waiters, n))

then the result is a RuntimeError exception:

    File "/usr/lib/python3.4/threading.py", line 358, in notify_all
      self.notify(len(self._waiters))
    File "/usr/lib/python3.4/threading.py", line 341, in notify
      waiters_to_notify = _deque(_islice(all_waiters, n))
  RuntimeError: deque mutated during iteration

(I have a server which makes extensive use of conditions on which this happens about once a day.)

This patch fixes this bug by moving wait()'s modification of self._waiters to be inside the lock, as suggested by Antoine Pitrou here: http://bugs.python.org/issue17385#msg183875
History
Date User Action Args
2014-08-11 23:47:11dougzsetrecipients: + dougz, pitrou
2014-08-11 23:47:11dougzsetmessageid: <1407800831.15.0.236937632355.issue22185@psf.upfronthosting.co.za>
2014-08-11 23:47:11dougzlinkissue22185 messages
2014-08-11 23:47:10dougzcreate