mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
add debug calls to self._note for the Semaphore class. This closes bug
443614. I will submit a new feature request and patch to threading.py and libthreading.tex to address the bounded semaphore issue.
This commit is contained in:
parent
dbec7d2c16
commit
b446fc7f27
1 changed files with 9 additions and 0 deletions
|
|
@ -261,9 +261,15 @@ class _Semaphore(_Verbose):
|
||||||
while self.__value == 0:
|
while self.__value == 0:
|
||||||
if not blocking:
|
if not blocking:
|
||||||
break
|
break
|
||||||
|
if __debug__:
|
||||||
|
self._note("%s.acquire(%s): blocked waiting, value=%s",
|
||||||
|
self, blocking, self.__value)
|
||||||
self.__cond.wait()
|
self.__cond.wait()
|
||||||
else:
|
else:
|
||||||
self.__value = self.__value - 1
|
self.__value = self.__value - 1
|
||||||
|
if __debug__:
|
||||||
|
self._note("%s.acquire: success, value=%s(%s)",
|
||||||
|
self, self.__value, self.__initial_value)
|
||||||
rc = 1
|
rc = 1
|
||||||
self.__cond.release()
|
self.__cond.release()
|
||||||
return rc
|
return rc
|
||||||
|
|
@ -271,6 +277,9 @@ class _Semaphore(_Verbose):
|
||||||
def release(self):
|
def release(self):
|
||||||
self.__cond.acquire()
|
self.__cond.acquire()
|
||||||
self.__value = self.__value + 1
|
self.__value = self.__value + 1
|
||||||
|
if __debug__:
|
||||||
|
self._note("%s.release: success, value=%s(%s)",
|
||||||
|
self, self.__value, self.__initial_value)
|
||||||
self.__cond.notify()
|
self.__cond.notify()
|
||||||
self.__cond.release()
|
self.__cond.release()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue