[Twisted-Python] Possible trial -u / threads bug

Mark Leonard mwl at point45.com
Fri Feb 9 10:04:06 EST 2007


I'm encountering a problem when using deferToThread in a unit test and 
running it with trial -u.

The code below demonstrates the problem. It fails (by timing out) on the 
second pass.

It seems to fail reliably on Twisted 2.5.0 (Python 2.5.0), but on a 
Twisted 2.0.1 (Python 2.4.1) installation it works just fine.

I think the problem is related to trial's cleanup of the threadpool. I 
did try (as a test) add reactor.threadpool.stop() to tearDown and 
reactor.threadpool.start() to setUp, but it had no effect on the second 
pass failure.

Can anybody confirm the problem and, if so, should I create a ticket for it?



from twisted.trial import unittest
from twisted.internet.threads import deferToThread

from time import sleep

def blockingFunc():

class DeferToThreadTestCase(unittest.TestCase):

     def testDeferToThread(self):
         return deferToThread(blockingFunc)

More information about the Twisted-Python mailing list