This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients sbt, tim.peters
Date 2013-10-04.17:29:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380907757.04.0.265944466599.issue19158@psf.upfronthosting.co.za>
In-reply-to
Content
Richard, that's a strange argument ;-)  Since, e.g., a BoundedSemaphore(1) is semantically equivalent to a mutex, it's like saying some_mutex.release() usually raises an exception if the mutex isn't held at the time - but maybe it won't.  If the docs _say_ it's not reliable, fair enough.  But they don't say that.  When a thread gimmick is _intended_ to be probabilistic, the docs say so (e.g., Queue.qsize()).

Probably would have been better if a bounded=False optional argument to Semaphore.__init__() had been added, rather than creating a new BoundedSemaphore class.  But, as is, it could easily be made reliable:

1. Change Semaphore's condition variable to use an RLock (instead of the current Lock).

2. Stuff the body of BoundedSemaphore.release() in a `with self._cond:` block.

Curiously, there doesn't appear to be a test that BoundedSemaphore.release ever raises ValueError.  So I'll readily agree that nobody ever took this seriously ;-)
History
Date User Action Args
2013-10-04 17:29:17tim.peterssetrecipients: + tim.peters, sbt
2013-10-04 17:29:17tim.peterssetmessageid: <1380907757.04.0.265944466599.issue19158@psf.upfronthosting.co.za>
2013-10-04 17:29:17tim.peterslinkissue19158 messages
2013-10-04 17:29:16tim.peterscreate