[Twisted-Python] Twisted 1.1.0 - AssertionError: reactor already installed

Joe Van Andel vanandel at atd.ucar.edu
Tue Dec 2 09:01:29 EST 2003


Using Twisted 1.1.0, Python 2.3.2, Redhat 9:

Python scripts using that import xmlprc before calling qtreactor.install()

e.g:
========================
from twisted.web.xmlrpc import Proxy

qtreactor.install(app)
=========================

fail with the traceback:

Traceback (most recent call last):
   File "qtdemo2.py", line 28, in ?
     qtreactor.install(app)
   File 
"/opt/local_rh90/lib/python2.3/site-packages/twisted/internet/qtreactor.py", 
line 197, in install
     installReactor(reactor)
   File 
"/opt/local_rh90/lib/python2.3/site-packages/twisted/internet/main.py", 
line 90, in installReactor
     assert not sys.modules.has_key('twisted.internet.reactor'), \
AssertionError: reactor already installed

====================================

Another demonstration of this problem:
=====================
 >>> from twisted.web.xmlrpc import Proxy
 >>> import sys
 >>> sys.modules.has_key('twisted.internet.reactor')
True
=========================
internet/main.py, installReactor() needs a more robust test whether a 
reactor has already been installed, rather than relying on whether 
twisted.internet.reactor has been imported.

The workaround is to move the import statement, but this isn't always a 
clean solution.

-- 
Joe VanAndel  	
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: vanandel at ucar dot edu
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: qtdemo2.py
Url: http://twistedmatrix.com/pipermail/twisted-python/attachments/20031202/76e8efcc/attachment.txt 


More information about the Twisted-Python mailing list