Frage

Python infinite loop code below:

i = 0
while True:
    i = i + 1

I know I can use import IPython; IPython.embed() or import pdb; pdb.set_trace() to pause loop running and get value of i --- run-time debug.

however, what I want is if I can "tapping" into this loop on demand probe value without pause it, similar to sniffer packets in network area?

PS: not as simple as print i to terminal directly.

Thanks.

War es hilfreich?

Lösung

Pyringe will do what you want.

Just grab it and run python -m pyringe, then you should be able to inject it in and debug like you wanted.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top