-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Semaphore.acquire() timeout parameter #39617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
New optional timeout parameter for Semaphore.acquire(). acquire(block=True, timeout=None) When invoked with blocking set to true and timeout set to |
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. |
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. |
Here is the diff for Python 2.7 |
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. |
See bpo-7316 for something more or less related. |
2.7 is in (mostly) feature freeze mode, so I'm retargetting this to 3.2. |
Modified patch committed in r80157 (py3k). Thank you! |
Thanks for applying! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: