Menu

REPL While It Works: Inspect a Running Python Program Without Pausing It
📰

REPL While It Works: Inspect a Running Python Program Without Pausing It

HackerNoon·David Kra·about 17 hours ago
#t2XMXxtu
#hackernoon#technology#this#global#print
Reading 0:00
15s threshold

Usually, without interrupting it, you cannot interactively debug, call functions in, or change the values of variables in a running python program. This article’s technique removes the limitation.

There are plenty of python examples showing how an executing script can interrupt its execution to present a console, where you can interact, and then resume execution. Here, the console is your choice of the Python interactive shell prompt, with its Read-Eval-Print Loop (aka REPL), or alternatively, the python PDB debugger.

I wanted to do that interacting, but without the interrupting and the resuming parts. While the long running execution continues to run, and without interrupting the program’s flow, I wanted to be able to access objects and invoke other functions concurrently. In the Snow White films, there is a song "Whistle While You Work." (Watch the 1937 version or 2025 version ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.