[Twisted-Python] How can I make twisted and dbus work together?

Matt Goodall matt at pollenation.net
Wed Jan 16 06:17:59 EST 2008


Justin Warren wrote:
> On Wed, 2008-01-16 at 17:28 +1100, hwan2265 at mail.usyd.edu.au wrote:
> 
>> But when I was running my code, I got a error:
>>
>> Traceback (most recent call last):
>>   File "dbustwisted.py", line 5, in <module>
>>     glib2reactor.install()
>>   File "/usr/lib/python2.5/site-packages/twisted/internet/glib2reactor.py",
>> line 33, in install
>>     return gtk2reactor.install(False)
>>   File "/usr/lib/python2.5/site-packages/twisted/internet/gtk2reactor.py",
>> line 270, in install
>>     installReactor(reactor)
>>   File "/usr/lib/python2.5/site-packages/twisted/internet/main.py", line
>> 24, in installReactor
>>     "reactor already installed"
>> AssertionError: reactor already installed
> 
> I suspect your problem may be here:
> 
>> if __name__ == "__main__":
>>     from twisted.internet import glib2reactor
>>     glib2reactor.install()
>>     ################################################
>>     # I added the 2 lines here and made the program crash
>>     ################################################
>>
>>     from twisted.internet import reactor
>       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> You've already imported glib2reactor, so you shouldn't import the
> default reactor as well. Try removing this line.

Actually, twisted.internet.reactor is quite magic. It is always the
installed reactor. However, if there is no reactor installed the first
time it is imported it will automatically install the default (select)
reactor.

I suspect that the real cause of the problem is that something is doing
a "from twisted.internet import reactor", causing the select reactor to
be installed, before the above code is getting the chance to install the
glib2reactor.

Looking at the code it must be a Twisted module that is the culprit.


- Matt


-- 
Matt Goodall
Technical Director, Pollenation Internet Ltd

Registered Number: 4382123
Registered Office: 237 Lidgett Lane, Leeds, West Yorkshire, LS17 6QR
A member of the Brunswick MCL Group of Companies

w: http://www.pollenation.net/
e: matt at pollenation.net
t: +44 (0) 113 2252500

This message may be confidential and the views expressed may not reflect
the views of my employers. Please read http://eudaimon-group.com/email
if you are uncertain what this means.




More information about the Twisted-Python mailing list