Python Stop current Python REPL command, but keep REPL session open?

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Python
Click For Summary
When a command in the Python REPL is stuck in a synchronous wait, such as when using websocket.recv() that is waiting for a message, the recommended method to terminate just that command is to use Control-C. This keyboard interrupt allows users to exit the blocking command and return to the REPL prompt without losing the entire session. This technique is commonly effective for handling situations where a command is unresponsive.
Swamp Thing
Insights Author
Messages
1,033
Reaction score
771
If you just typed in a command into the Python repl, and it is stuck in a synchronous "waiting-for-something-to-happen", how can we terminate just that command and return to the same repl session?

For example, say we typed websocket.recv() and the websocket is waiting for a message... how can we end that and get back to the repl prompt without losing the whole session?
 
Technology news on Phys.org
Try control-c it usually works as a keyboard interrupt.
 
  • Like
Likes PeterDonis and Swamp Thing

Similar threads

Replies
2
Views
959
Replies
15
Views
2K
Replies
4
Views
4K
Replies
22
Views
5K
Replies
3
Views
3K