Ответ 1
Кажется, это работает для меня:
#!/usr/bin/python
import time
import threading
import pdb
def f():
while True:
time.sleep(1.0)
print 'tick-tock' # Put a breakpoint here...
pdb.set_trace()
th = threading.Thread(target=f)
th.start()
time.sleep(30)
print 'done.'
Во время выполнения:
┌───┤/tmp├──────────────────────────────────────┤0.43├──────┤20140612.211049├───
└─┤[email protected]:pts/1│ret=1├────> python test.py
tick-tock
> /tmp/test.py(8)f()
-> while True:
(Pdb) list
3 import time
4 import threading
5 import pdb
6
7 def f():
8 -> while True:
9 time.sleep(1.0)
10 print 'tick-tock' # Put a breakpoint here...
11 pdb.set_trace()
12
13 th = threading.Thread(target=f)
(Pdb) c
tick-tock
> /tmp/test.py(8)f()
-> while True:
(Pdb)