[Python-bugs-list] [ python-Bugs-443614 ] enhancement for threading._Semaphore

noreply@sourceforge.net noreply@sourceforge.net
Fri, 17 Aug 2001 09:57:49 -0700


Bugs item #443614, was opened at 2001-07-22 14:16
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443614&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Skip Montanaro (montanaro)
>Assigned to: Tim Peters (tim_one)
Summary: enhancement for threading._Semaphore

Initial Comment:
The threading._Semaphore class subclasses
threading._Verbose
but takes no advantage of this, never calling
self._note.  In
addition, it seems to me that most of the time it would
be
a bug if a semaphore is released more times than it is
acquired.  The attached patch adds to calls to
self._note
similar to those in threading._RLock adds a new
instance
variable, __initial_value, and adds an assert to
_Semaphore.release to compare the current value of the
semaphore with its initial value.

If it is felt that the semantic change to the
_Semaphore
class caused by the addition of the assert statement
would
break code, I recommend that  _Semaphore be subclassed
with the release method overridden to include the
assert
check.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-17 09:57

Message:
Logged In: YES 
user_id=6380

Looks good to me.

Tim, do you approve of this?  If so, assign to Skip for
checkin.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443614&group_id=5470