[New-bugs-announce] [issue10978] Add optional argument to Semaphore.release for releasing multiple threads

Raymond Hettinger report at bugs.python.org
Sat Jan 22 01:15:36 CET 2011


New submission from Raymond Hettinger <rhettinger at users.sourceforge.net>:

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.

----------
components: Library (Lib)
files: sem.diff
keywords: patch
messages: 126804
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add optional argument to Semaphore.release for releasing multiple threads
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file20483/sem.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10978>
_______________________________________


More information about the New-bugs-announce mailing list