Issue 14087: multiprocessing.Condition.wait_for missing - Python tracker (original) (raw)

Created on 2012-02-22 15:01 by sbt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cond_wait_for.patch sbt,2012-02-23 13:41
cond_wait_for.patch sbt,2012-02-24 13:26
cond_wait_for.patch sbt,2012-04-07 22:36 review
cond_wait_for.patch sbt,2012-04-16 14:42 review
Messages (11)
msg153956 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-02-22 15:01
multiprocessing.Condition is missing a counterpart for the wait_for() method added to threading.Condition in Python 3.2. I will work on a patch.
msg154063 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-02-23 13:41
Patch which just copies the implementation from threading.
msg154093 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2012-02-23 22:06
In test/test_multiprocessing.py: """ def test_waitfor(self): [...] with cond: result = cond.wait_for(lambda : state.value==0) self.assertTrue(result) self.assertEqual(state.value, 0) for i in range(4): time.sleep(0.01) with cond: state.value += 1 cond.notify() """ Shouldn't the `for` loop be outside the outer `with` block? In Lib/multiprocessing/managers.py: Is there a good reason why the wait_for() proxy method can't simply be implemented as: return self._callmethod('wait_for', (predicate, timeout))? (There may be, I just didn't check). Finally, the documentation should be updated (Doc/library/multiprocessing.rst). Otherwise, it would probably be better if you could submit a contributor agreement (and also maybe update your name on the tracker), unless that's a problem for you?
msg154135 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-02-24 13:26
> Shouldn't the `for` loop be outside the outer `with` block? Yes. > In Lib/multiprocessing/managers.py: > Is there a good reason why the wait_for() proxy method can't simply be > implemented as: > return self._callmethod('wait_for', (predicate, timeout))? > > (There may be, I just didn't check). That would only work if predicate is picklable, which is unlikely to be the case. (The lambda functions used in the unit tests are not picklable.) > Finally, the documentation should be updated > (Doc/library/multiprocessing.rst). Fixed in new patch. > Otherwise, it would probably be better if you could submit a contributor > agreement (and also maybe update your name on the tracker), unless that's > a problem for you? I will try to submit it over the weekend.
msg157244 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-03-31 23:54
AFAICT (Raw)Value relies on ctypes, so the tests should be skipped if ctypes is unavailable. Or I guess you could use a Semaphore instead.
msg157762 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-04-07 22:36
New patch skips tests if ctypes not available.
msg158459 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-04-16 14:42
New patch which calculates endtime outside loop.
msg158497 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-04-16 20:16
Charles-François, will you take this one? :)
msg158533 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2012-04-17 07:32
> Charles-François, will you take this one? :) Yes :-)
msg158557 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-04-17 16:46
New changeset 5606ee052783 by Charles-François Natali in branch 'default': Issue #14087: multiprocessing: add Condition.wait_for(). Patch by sbt. http://hg.python.org/cpython/rev/5606ee052783
msg158559 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2012-04-17 17:30
Committed. Thanks for the patch, and sorry for the delay!
History
Date User Action Args
2022-04-11 14:57:27 admin set github: 58295
2012-04-17 17:30:15 neologix set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2012-04-17 16:46:49 python-dev set nosy: + python-devmessages: +
2012-04-17 07:32:52 neologix set messages: +
2012-04-16 20:16:30 pitrou set messages: +
2012-04-16 14:42:52 sbt set files: + cond_wait_for.patchmessages: +
2012-04-07 22:36:42 sbt set files: + cond_wait_for.patchmessages: +
2012-03-31 23:54:06 pitrou set messages: +
2012-03-31 23:42:54 pitrou link issue14059 dependencies
2012-03-26 14:53:33 neologix set nosy: + pitroustage: commit review
2012-02-24 13:26:56 sbt set files: + cond_wait_for.patchmessages: +
2012-02-23 22:06:20 neologix set nosy: + neologixmessages: +
2012-02-23 13:41:23 sbt set files: + cond_wait_for.patchkeywords: + patchmessages: +
2012-02-22 15:01:24 sbt create