[Python-bugs-list] [ python-Bugs-452836 ] BoundedSemaphore class
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 20 Aug 2001 11:49:33 -0700
Bugs item #452836, was opened at 2001-08-18 23:01
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452836&group_id=5470
Category: Python Library
Group: Feature Request
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: BoundedSemaphore class
Initial Comment:
Per Guido's request, here's a simple BoundedSemaphore
class, including doc update (and simple example)
as well as a rudimentary test_threading.py which
draws heavily from test_thread.py.
Assigned to Tim, since he's probably the most likely
person to check the BoundedSemaphore code.
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-08-20 11:49
Message:
Logged In: YES
user_id=3066
Documentation checked in as Doc/lib/libthreading.tex
revision 1.10.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2001-08-20 06:50
Message:
Logged In: YES
user_id=44345
Thanks. I made a change to the docs that should better
reflect how BoundedSemaphore objects behave in the face
of errors, and am assigning to Fred for doc review (new
class and a simple example). I uploaded a new version of
threading.diff (and deleted the old one this time).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-08-20 00:46
Message:
Logged In: YES
user_id=31435
Cool! Accepted for the code changes, and back to Skip for
checkin. Reassign to Fred for doc changes, if you want.
I would like to see the docs clarified on one point. When
it says
"""
ensures that its current value never exceeds its initial
value
"""
I have no idea what "ensures" means. Would be better to
tell the plain truth, i.e. that the release() method
specifically raises ValueError specifically in such cases;
a reader could easily imagine, e.g., that instead a
BoundedSemaphore "ensures" this condition by blocking until
someone else does an acquire (which would be symmetric with
acquire() blocking at *its* limit until someone does a
release(), so isn't an implausible guess).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-08-20 00:35
Message:
Logged In: YES
user_id=31435
Deleted the old patch.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-08-19 19:34
Message:
Logged In: YES
user_id=31435
Thanks, Skip! I assigned this back to me (no time this
instant; will get back to it later tonight).
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2001-08-19 17:47
Message:
Logged In: YES
user_id=44345
I got rid of the assert and just test the value, raising
ValueError if it's out of whack. Actually, there was
another bug before as well. I shouldn't have been testing
self.__value, but self._Semaphore__value. In the
test_threading.py file I wrote for some reason I called
Semaphore instead of BoundedSemaphore. That's also been
fixed.
I modelled the name of self.__initial_value after
self.__value, but have changed it to only have a single
leading underscore.
Skip
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-08-19 14:32
Message:
Logged In: YES
user_id=31435
Back to Skip.
+ Think of a way to do this without using "assert":
BoundedSempahore doesn't do its job under -O as-is, because
asserts vanish, and UnreliableBoundedSemaphore would be an
unwieldy class name <wink>.
+ Consider renaming __initial_value to _initial_value;
there's no reason to hide this from subclasses, right?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452836&group_id=5470