I have a locked conditional variable, which is in waiting state. I want to notify it from a separate thread using a Timer. The Lock is acquired successfully, however when calling notify, it raises an exception about the lock being not acquired.
I've tried different approaches in Python 2.7 and 3.6, and it behaves the same way.
from threading import Timer, Lock, Condition
lock = Lock()
cond = Condition(lock)
timer = Timer(2, lambda: cond.notify_all())
with cond:
timer.start()
cond.wait()
I am getting this error:
File "c:\python27\Lib\threading.py", line 384, in notify
raise RuntimeError("cannot notify on un-acquired lock")