Issue 31977: threading.Condition can not work with threading.Semaphore (original) (raw)
Issue31977
Created on 2017-11-08 05:12 by 张晓林, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg305807 - (view) | Author: 张晓林 (张晓林) | Date: 2017-11-08 05:12 |
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? | ||
msg305910 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2017-11-08 21:29 |
Why do you want Condition to work with a Semaphore? What would be achieved? A Semaphore is not a lock, it's an other kind of concurrency primitive. I don't think there's any point in detailing it any futrher. | ||
msg305938 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2017-11-09 06:11 |
I concur with Antoine and don't think there is a real issue here to be solved. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:54 | admin | set | github: 76158 |
2017-11-09 16:42:29 | pitrou | set | status: open -> closedresolution: fixedstage: resolved |
2017-11-09 06:11:59 | rhettinger | set | nosy: + rhettingermessages: + |
2017-11-08 21:29:49 | pitrou | set | nosy: + pitrou, tim.petersmessages: + |
2017-11-08 06:25:11 | 张晓林 | set | type: resource usage -> behavior |
2017-11-08 05:12:05 | 张晓林 | create |