In windows, python 3.4
import threading
l = threading.Lock()
l.acquire()
l.acquire()
triggers a deadlock, and CTRL+C cannot stop it. You have to kill the process.
On the other hand:
import time
time.sleep(100000)
can be interrupted anytime with CTRL+C (I've read otherwise on some other SO questions/answers but it works fine)
Both rely on OS system calls so why is it not working for locks and it is working for sleep
? Is it because time.sleep(1000000)
is (roughly) equivalent to for i in range(10000000): time.sleep(0.1)
and thus can be finely interrupted?