Skip to content

carlesso/qtreactor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a fork of http://github.com/ghtdak/qtreactor

I add the concept of "BUS" to the reactor.

You can subsribe on it by calling:                                          
                                                                                                              
    reactor.bus.subscribe('test_function(int, int)', test_function)                                        
                                                                                                              
and "emit" all callbacks linked to a signature:                                                               
                                                                                                              
    reactor.bus.emit('test_function(int, int)', 1, 2)                                                      
                                                                                                              
You can take a look at bus_test.py                                                                            
                                                                                                              
TODO: added parameters check

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

Unpack this directory into your PYTHONPATH.

test with:

trial --reactor=qt4 twisted (or twisted.test or twisted.test.test_internet)

If you're using Qt 4.4 and the newer versions of twisted, I've been using:

trial --reactor=qt4 --without-module gtk2reactor --recursionlimit=2000
twisted 2>&1 | tee trial.out

particularly on a 64 bit OS... I have no idea why the recursion limit matters more on 64 bit machines... maybe there's deeper to go so it does :-)

= Contributors = 

Many thanks to Darren Dale who provided the patch to fix the reactor for Qt4.4

= Using the Qt4Reactor =

In your own code, BEFORE you import the reactor...

app = QApplication(sys.argv)
import qt4reactor
qt4reactor.install()

= Gui =

There is a way to run trial using a gui... in bin, there is a routine
gtrial.  Put that in the same directory as trial and it pops up a
trivial gui... hit the buton and it all runs the same... don't use the
--reactor option when calling gtrial... but all the other options
appear to work.  This was just to make sure there wasn't anything
strange with guis which there doesn't appear to be

If you're writing a conventional Qt application and just want twisted
as an addon, you can get that by calling reactor.runReturn() instead
of run().  This call needs to occur after your installation of of the
reactor and after QApplication.exec_() (or QCoreApplication.exec_()
whichever you are using.

reactor.run() will also work as expected in a typical twisted application

more docs in qt4reactor.py

Note that if a QApplication or QCoreApplication instance isn't
constructed prior to calling reactor run, an internally owned
QCoreApplication is created and destroyed. This won't work if you call
runReturn instead of run unless you take responsibility for wacking
QCoreApplication yourself...

However, most users want this reactor to do gui stuff so this
shouldn't be an issue.

Performance impact of Qt has been reduced by minimizing use of
signaling which is expensive.  241s for qt4reactor vs 194s for select
for entire twisted trial suite.

-glenn

--
Glenn H. Tarbox, PhD
glenn@tarbox.org

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%