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

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Python
AI Thread 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,028
Reaction score
768
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
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
2
Views
777
Replies
15
Views
2K
Replies
4
Views
4K
Replies
22
Views
5K
Replies
3
Views
3K
Back
Top