这对我有用:
import threading
import pdb
class SomeThread(threading.Thread):
def run(self):
a = 1
print a
pdb.set_trace()
def main():
print 'hola'
pdb.set_trace()
someThread = SomeThread()
someThread.start()
if __name__ == '__main__':
main()
这给了我:
C:\Code>python b.py
hola
> c:\code\b.py(13)main()
-> someThread = SomeThread()
(Pdb) l
8 pdb.set_trace()
9
10 def main():
11 print 'hola'
12 pdb.set_trace()
13 -> someThread = SomeThread()
14 someThread.start()
15
16 if __name__ == '__main__':
17 main()
[EOF]
(Pdb) c
1
--Return--
> c:\code\b.py(8)run()->None
-> pdb.set_trace()
(Pdb) l
3
4 class SomeThread(threading.Thread):
5 def run(self):
6 a = 1
7 print a
8 -> pdb.set_trace()
9
10 def main():
11 print 'hola'
12 pdb.set_trace()
13 someThread = SomeThread()
(Pdb)
这是在 Windows 7 和 Python 2.7.2 下。您使用的是什么操作系统和 Python 版本?