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 <>
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/", line 358, in notify_all
    File "/usr/lib/python3.4/", 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:
Date User Action Args
2014-08-11 23:47:11dougzsetrecipients: + dougz, pitrou
2014-08-11 23:47:11dougzsetmessageid: <>
2014-08-11 23:47:11dougzlinkissue22185 messages
2014-08-11 23:47:10dougzcreate