문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top