simple threading.Thread and Semaphores hang

lnenov lnenov at mm-sol.com
Mon Dec 6 07:36:41 EST 2010


Hi,

My application hangs on exit.
I have isoleted this piece of code that reproduces the error: (the time 
module is extra and not needed to reproduce)

import threading
import time

def func():
     b = threading.Semaphore(value=0)
     b.acquire()

a = threading.Thread(target=func)
a.start()

time.sleep(2)
quit()

When SystemExit is raised, nothing happens. Python hangs.

pdb does seem to have problem with this code too:
  pdb smth.py
...
(Pdb) Traceback (most recent call last):
   File "/usr/bin/pdb", line 1319, in <module>
     pdb.main()
   File "/usr/lib/python2.6/pdb.py", line 1312, in main
     pdb.interaction(None, t)
   File "/usr/lib/python2.6/pdb.py", line 198, in interaction
     self.cmdloop()
   File "/usr/lib/python2.6/cmd.py", line 130, in cmdloop
     line = raw_input(self.prompt)
ValueError: I/O operation on closed file

Any help would be appreciated,
Lyudmil



More information about the Python-list mailing list