What steps will reproduce the problem?
I often use code like
if lock.acquire(): try: pass finally: lock.release()
acquire() simply returns on successful lock acquiry. This renders above code inoperable, since None evaluates to False.
What is the expected output? What do you see instead? lock.acquire() should return True on successful acquire.
What version of the product are you using? On what operating system? Any
Please provide any additional information below. None
Comment #1
Posted on May 13, 2013 by Grumpy LionIs there some reason you don't use
with lock: do_stuff
? That will do the acquire/release dance automatically.
Comment #2
Posted on May 14, 2013 by Swift RabbitWell, two reasons, actually: with lock: do_stuff does not support the timeout argument, and lock.acquire() from threading/multiprocessing returns True as well, and it's nice for APIs to have consistent behaviour.
Comment #3
Posted on Jun 19, 2013 by Massive WombatComment deleted
Comment #4
Posted on Jun 19, 2013 by Massive WombatComment deleted
Comment #5
Posted on Jun 19, 2013 by Helpful CamelActually, you can do with MyLock(timeout=42): pass
Comment #6
Posted on Aug 25, 2013 by Grumpy LionChristian, does gc@birzan.org's comment work for you?
Status: New
Labels:
Type-Defect
Priority-Medium