Winand

Untitled

Sep 10th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #WORKER THREAD
  2. with x2:
  3.     if x1.locked():
  4.         _thread.interrupt_main()
  5.     else: print("nothing to interrupt")
  6.  
  7. #MAIN THREAD
  8. with x1:
  9.     try:
  10.         #while 1: pass #some long running code
  11.         while x2.locked(): pass
  12.     except KeyboardInterrupt: print("interrupted")
Advertisement
Add Comment
Please, Sign In to add comment