Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import _thread
- import time
- import sys
- import dis
- print(__file__)
- print(sys.executable)
- def child_thread():
- time.sleep(1)
- print('child interrupting parent')
- _thread.interrupt_main()
- dis.dis(child_thread)
- dis.dis(sys._getframe().f_code)
- if __name__ == '__main__':
- t = threading.Thread(target=child_thread, args=())
- t.start()
- print('parent looping')
- try:
- while True:
- time.sleep(1)
- except KeyboardInterrupt:
- print('caught interruption raised from user or child thread :)')
- except TypeError as e:
- print('why would I ever catch a TypeError?')
- print(time.sleep)
- raise
- except Exception as e:
- print('Strange Exception Received ')
- raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement