[New-bugs-announce] [issue31977] threading.Condition can not work with threading.Semaphore

张晓林 report at bugs.python.org
Wed Nov 8 00:12:05 EST 2017


New submission from 张晓林 <petelin1120 at gmail.com>:

the python document say Condition work will Locks, like RLock...

but i find it not work with Semaphore, because Condition._is_owned is like this

    def _is_owned(self):
        # Return True if lock is owned by current_thread.
        # This method is called only if _lock doesn't have _is_owned().
        if self._lock.acquire(0):
            self._lock.release()
            return False
        else:
            return True

this work for RLock, but not work for Semaphore, and Semaphore do not have it's own _is_owned implement.

i spend a lot of time on this issue. maybe fix it, or document it out?

----------
messages: 305807
nosy: 张晓林
priority: normal
severity: normal
status: open
title: threading.Condition can not work with threading.Semaphore
type: resource usage
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31977>
_______________________________________


More information about the New-bugs-announce mailing list