Reputation: 2387
I use iPython on Windows. I'm currently making a python script that can be stuck on socket reception (I have not implemented robustness on this part yet).
I'm trying every usual killing process key combinations (at least the ones I know) but iPython is stuck and I have to close and reopen it. I tried Ctrl+C, Ctrl+Z, Ctrl+D, I don't know if there are other combinations.
Has anyone gone through this kind of problem ?
thank you
Alexandre
Upvotes: 3
Views: 992
Reputation: 140168
Some blocking operations (related to the operating system) cannot be interrupted properly (see cannot interrupt lock.acquire() whereas I can interrupt time.sleep())
I propose some approach which requires you to know what's going on in your code.
KeyboardInterrupt
I've created an example using thread locks for simplicity's sake. You can adapt this to sockets or whatever blocking resource:
import threading
import time,sys
l = threading.Lock()
def run():
global l
l.acquire()
l.acquire()
t = threading.Thread(target=run)
t.start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
print("quitting")
l.release() # now thread can exit safely
break
Upvotes: 2
Reputation: 157
Try the following command:
exit
or try to restart the kernel.
Upvotes: -1