[issue22185] Occasional RuntimeError from Condition.notify

2014-08-11 Thread Doug Zongker

New submission from Doug Zongker:

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

--
components: Library (Lib)
files: fix.diff
keywords: patch
messages: 225208
nosy: dougz, pitrou
priority: normal
severity: normal
status: open
title: Occasional RuntimeError from Condition.notify
type: crash
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file36351/fix.diff

___
Python tracker 
<http://bugs.python.org/issue22185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22185] Occasional RuntimeError from Condition.notify

2014-08-29 Thread Doug Zongker

Doug Zongker added the comment:

So, what happens now?  What do I need to do to make progress on this?

--

___
Python tracker 
<http://bugs.python.org/issue22185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com