Issue 850728: Semaphore.acquire() timeout parameter (original) (raw)

Created on 2003-11-28 12:47 by hdima, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
threading.diff hdima,2003-11-28 12:47 Lib/threading.py, Doc/lib/libthreading.tex
sem_timeout.diff torsten,2010-02-19 23:46 updated patch for py3k
sem_timeout_trunk.diff torsten,2010-02-20 00:01 diff for trunk (2.7)
Messages (9)
msg44957 - (view) Author: Dmitry Vasiliev (hdima) Date: 2003-11-28 12:47
New optional timeout parameter for Semaphore.acquire(). acquire(block=True, timeout=None) When invoked with blocking set to true and timeout set to a positive number, it blocks at most timeout seconds and return false if the internal counter is still zero; otherwise return true.
msg44958 - (view) Author: Stephen Hansen (aptshansen) Date: 2007-03-16 07:08
This applies cleanly against the HEAD, and passes all of the threading tests. I don't see any reason NOT to have a timeout on the Semaphores, and the implementation is clean enough. I do think that it should have some tests written since its a newish feature before being accepted, though.
msg99602 - (view) Author: Torsten Landschoff (torsten) * Date: 2010-02-19 23:46
I have been bitten by this omission from the python libs recently. I ended up copying the code from this diff into my script. I'd rather have this available with each python installation, so I updated the patch to include test cases as well as ReST documentation updates. Attached is the patch for Python 3.x (against current py3k). I'll send an updated patch for 2.7 as well.
msg99605 - (view) Author: Torsten Landschoff (torsten) * Date: 2010-02-20 00:01
Here is the diff for Python 2.7
msg100031 - (view) Author: Torsten Landschoff (torsten) * Date: 2010-02-24 12:03
I just noticed that the multiprocessing module supports the timeout parameter of Semaphore. So the patch would also fix the documentation of multiprocessing.Semaphore since it refers to threading.Semaphore.
msg100053 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-02-24 17:34
See for something more or less related.
msg103227 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-15 16:05
2.7 is in (mostly) feature freeze mode, so I'm retargetting this to 3.2. (yes, this issue is very old; sorry) I will try to include it (or a variant thereof; the non-blocking + timeout combination doesn't make much sense, so I plan to forbid it) to the py3k branch soon.
msg103457 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-17 23:53
Modified patch committed in r80157 (py3k). Thank you!
msg120651 - (view) Author: Torsten Landschoff (torsten) * Date: 2010-11-06 22:11
Thanks for applying!
History
Date User Action Args
2022-04-11 14:56:01 admin set github: 39617
2010-11-06 22:11:46 torsten set messages: +
2010-04-17 23:53:11 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2010-04-15 16:05:08 pitrou set assignee: pitroustage: test needed -> patch reviewmessages: + versions: - Python 2.7
2010-04-15 11:52:44 asvetlov set nosy: + asvetlov
2010-02-24 17:34:49 pitrou set nosy: + pitroumessages: +
2010-02-24 12:03:10 torsten set messages: +
2010-02-20 00:01:31 torsten set files: + sem_timeout_trunk.diffmessages: +
2010-02-19 23:46:30 torsten set files: + sem_timeout.diffversions: + Python 3.2nosy: + torstenmessages: +
2009-02-14 12:31:50 ajaksu2 set stage: test neededtype: enhancementversions: + Python 2.7, - Python 2.4
2003-11-28 12:47:33 hdima create