Message: 8 Date: Fri, 30 Oct 2009 17:38:12 +0800 From: Crispin Wellington firstname.lastname@example.org Subject: [Twisted-Python] Using a custom reactor in twisted trial for test cases? To: email@example.com Message-ID: 1256895492.4200.9.camel@wolfwood Content-Type: text/plain
I am using twisted trial to run test cases for an application. The application however uses stackless python and has a custom stackless reactor. I implemented this reactor like this...
For better or worse, much of what you have discussed have been fleshed out about two years ago in this mailing list and in stackless. Also I outline strategies in the PyCon 2008 talk "Adventures in Stackless Twisted Integration." Personally, I don't know why more people don't use Stackless with Twisted.
1) Based on what I have seen, you don't need to write a custom reactor (I still remember Glyph setting me straight on that one). At least for what you are doing :-).
2) Use task.loopingCall to make the reactor periodically yield.
l = task.LoopingCall(stackless.schedule) l.start(.01)
however there is some weird interaction between Stackless Python 2.6 and Twisted so you may have to do
def __tick__(): stackless.schedule
or play with the recursionlimit variable. I have not gotten to the bottom of that problem.