开发者

Trace/BPT trap with Python threading module

The following code dies with Trace/BPT trap:

from tvdb_api import Tvdb
from threading import Thread

class GrabStuff(Thread):
    def run(self):
        t = Tvdb()

def main():
    threads = [GrabStuff() for x in range(1)]
    [x.start() for x in threads]
    [x.join() for x in threads]

if __name__ == '__main__':
    main()

The error occurs due to the Tvdb(), but I have no idea why.

I ran the code with python -m pdb thes开发者_如何学JAVAcript.py and stepped through the code, and it dies at after the following lines:

> .../threading.py(468)start()
-> _active_limbo_lock.acquire()
(Pdb) 
> .../threading.py(469)start()
-> _limbo[self] = self
(Pdb) 
> .../threading.py(470)start()
-> _active_limbo_lock.release()
(Pdb) 
> .../threading.py(471)start()
-> _start_new_thread(self.__bootstrap, ())
(Pdb) 
> .../threading.py(472)start()
-> self.__started.wait()
(Pdb) Trace/BPT trap

(I replaced the full path to threading.py with ...)

The same problem occurs with 2.6.1 and 2.5.4. The machine is running on OS X 10.6.1 Snow Leopard. The tvdb_api code can be found on github.com/dbr/tvdb_api


Bad things can happen when importing modules for the first time in a thread on OS X 10.6. See, for instance, this issue. As a workaround, try looking through Tvdb and add its complete chain of imports to the main module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜