Re: sys.stderr and thread



Peter Hansen wrote:
Michele Petrazzo wrote:
This is the exception:

Unhandled exception in thread started by <bound method
Thread.__bootstrap of <Thread(Thread-1, stopped daemon)>>
Traceback (most recent call last):
  File "C:\Python23\lib\threading.py", line 451, in __bootstrap
    self.__stop()
  File "C:\Python23\lib\threading.py", line 460, in __stop
    self.__block.notifyAll()
  File "C:\Python23\lib\threading.py", line 256, in notifyAll
    self.notify(len(self.__waiters))
  File "C:\Python23\lib\threading.py", line 238, in notify
    currentThread() # for side-effect
TypeError: 'NoneType' object is not callable


One of the steps the interpreter takes is to go through all modules and rebind all globals to None. I suspect currentThread is a global in the above (although I thought that particular issue was fixed in Python 2.4... are you running an older version?).

Like you can see (c:\python23), I'm working with python 2.3. I'll try with 2.4.



The "simplest" thing to do is to ignore this exception because it's spurious". One way to ignore it is simply to wrap that particular daemon thread's "run" method with a "try/except: pass" so that all exceptions are swallowed quietly. Often that's not preferable, however, since it will of course swallow real exceptions too.

After a lot of tries, I modify the twisted threadselectreactor with your hack, and now it work.


-Peter

Thanks a lot, Michele .