Created on 2011-01-22 00:15 by rhettinger, last changed 2019-08-29 08:45 by rhettinger. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| sem.diff | rhettinger, 2011-01-22 00:15 | Patch to threading.py | review | |
| multirelease.diff | rhettinger, 2014-06-22 02:33 | Update patch to Py3.5. Add test and docs | review | |
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 15588 | merged | rhettinger, 2019-08-29 08:23 | |
| Messages (6) | |||
|---|---|---|---|
| msg126804 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2011-01-22 00:15 | |
Call sem.release(5) would have the same effect as:
with lock:
for i in range(5):
sem.release()
The use case is when a single semaphore is holding up multiple threads and needs to release them all. According to "The Little Book of Semaphores <http://greenteapress.com/semaphores/>", this is a common design pattern.
Basic patch attached. If the proposal meets with acceptance, will add tests and a doc update.
|
|||
| msg135005 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2011-05-02 20:02 | |
Your patch uses tabs for indentation. Otherwise, looks good on the principle. |
|||
| msg221028 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2014-06-19 21:44 | |
Seems good to proceed as there are no dissenters. |
|||
| msg221213 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2014-06-22 02:33 | |
Updated patch (with tests and docs). |
|||
| msg221585 - (view) | Author: Josh Rosenberg (josh.r) * | Date: 2014-06-25 23:55 | |
Never know whether to comment on issue itself, but just in case: There are issues with the patch when n < 0 is passed, as n is not sanity checked, which would break the Semaphore invariant (value must be >= 0). n == 0 is also a weird value, but harmless if passed; release(0) would acquire and release the lock but otherwise act as a noop. |
|||
| msg350757 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-08-29 08:45 | |
New changeset 35f6301d68bdb0517be284421782d64407dfe72c by Raymond Hettinger in branch 'master': bpo-10978: Semaphores can release multiple threads at a time (GH-15588) https://github.com/python/cpython/commit/35f6301d68bdb0517be284421782d64407dfe72c |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-08-29 08:45:42 | rhettinger | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-08-29 08:45:29 | rhettinger | set | messages: + msg350757 |
| 2019-08-29 08:32:21 | rhettinger | set | versions: + Python 3.9, - Python 3.5 |
| 2019-08-29 08:23:29 | rhettinger | set | pull_requests: + pull_request15264 |
| 2019-03-15 23:52:42 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2014-06-25 23:55:38 | josh.r | set | messages: + msg221585 |
| 2014-06-25 02:20:57 | josh.r | set | nosy:
+ josh.r |
| 2014-06-22 14:04:36 | pitrou | set | nosy:
+ neologix |
| 2014-06-22 02:33:55 | rhettinger | set | files:
+ multirelease.diff versions: + Python 3.5, - Python 3.3 nosy: + tim.peters messages: + msg221213 |
| 2014-06-19 21:44:16 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg221028 |
| 2011-05-02 20:02:25 | pitrou | set | nosy:
+ pitrou messages: + msg135005 type: behavior -> enhancement |
| 2011-03-23 06:00:11 | rhettinger | set | assignee: rhettinger |
| 2011-01-22 00:15:34 | rhettinger | create | |