[Twisted-Python] RE: ipython & twisted: no module named threading

Mike Winter (miwinter) miwinter at cisco.com
Thu Jun 19 13:08:57 EDT 2008


This is a record of analysis and consequent workaround to enable running
ipython and Twisted's trial. Posting to twisted, it probably requires no
action from twisted team since I suspect IPython is not dealing with the
situation correctly. Ipython needs to resolve the problem w/ a 

try: 
  import thread
except ImportException:  
  print "failed to import thread"
  import dummy_thread as thread

For ipython to 'work' I copy dummy_thread.py thread.py, then when I run
trial or twistd I see the following exception. If I delete the thread.py
this does not show up, but ipython stops working.

Exception exceptions.ImportError: 'No module named threading' in <bound
method local.__del__ of <_threading_local.local object at 0xb72f6874>>
ignored 

(venv)[miwinter at sawwing test]$ twistd -ny finger.tac shows the same
exception (from twisted's finger tutorial).

Python -V 2.4.5 and 2.5.1 and 2.5.2
Ipython-0.8.2       *
Twisted 8.1.0
virtualenv 1.0
CVSToys 1.0.10

python -m virtualenv venv
. venv/bin/activate
(venv)# make InstallTwisted (cd Twisted-8.1.0; python setup.py install)
(venv)# make InstallBuildbot (easy_install buildbot) (venv)# trial
buildbot.test.test_twisted .... Shows the above problem:
[skip]
PASSED (skips=37, successes=271)
Exception exceptions.AttributeError: "'NoneType' object has no attribute
'StringIO'" in <bound method RemoteReference.__del__ of
<twisted.spread.pb.RemoteReference instance at 0xb6856aec>> ignored
Exception exceptions.ImportError: 'No module named threading' in <bound
method local.__del__ of <_threading_local.local object at 0xb72dacfc>>
ignored

test main-trunk]$  md5sum lib/python2.4/thread*py
lib/python2.4/dummy_thread*py
3783492a0969521ff1266ec6c3e570c2  lib/python2.4/threading.py 
38db2323ac32ddbcad69888abd30d21f  lib/python2.4/dummy_threading.py 
52a6d92c98cc5a2eb68a3b1dde16e58b  lib/python2.4/thread.py 
52a6d92c98cc5a2eb68a3b1dde16e58b  lib/python2.4/dummy_thread.py

Without thread.py ipython will fail to start, so in my makefile I do: 

fixThread: bin/python lib/python$(PY_MACRO_VERSION)/thread.py

lib/python$(PY_MACRO_VERSION)/thread.py:
    (cd lib/python$(PY_MACRO_VERSION); cp dummy_thread.py thread.py)

This exception (see start of email) is perhaps caused by dummy.py
lacking some of the guts that some inappropriately intimate part of
threading.py depends upon. 

w/o target fixThread ipython will not start! Since resolving this by
bandaiding Makefile I thought it worthy to report that my patch to my
Makefile was to add target unfixThread: to reverse the effects of
fixThread which was a hack for ipython to work, better fix ipython
somehow.




More information about the Twisted-Python mailing list