[Twisted-Python] leakage between tests with trial when code under test uses deferToThread
![](https://secure.gravatar.com/avatar/599519579a707ab348b35cf68477df08.jpg?s=120&d=mm&r=g)
Hi All, Does trial do anything to clean up stuff that's been passed to deferToThread? I'm seeing what looks like leakage between tests where stuff that is deferred to a thread from a LoopingCall is resulting in a DelayedCall ending up in the reactor for the next test. Does that ring any bells? cheers, Chris
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
Nope. It does its best to clean up stuff that it knows is "in" the reactor (sockets, timers, and the like), but since threads can kind of do ~whatever~ there hasn't been support for that. deferToThread is a bit of a special case and you make a good point here: there should probably be special support for it in trial.
I'm seeing what looks like leakage between tests where stuff that is deferred to a thread from a LoopingCall is resulting in a DelayedCall ending up in the reactor for the next test. Does that ring any bells?
That can definitely happen. For the time being you probably want to add your own deferToThread layer and have a testCase.addCleanup that makes sure all the relevant Deferreds have fired. -g
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
Nope. It does its best to clean up stuff that it knows is "in" the reactor (sockets, timers, and the like), but since threads can kind of do ~whatever~ there hasn't been support for that. deferToThread is a bit of a special case and you make a good point here: there should probably be special support for it in trial.
I'm seeing what looks like leakage between tests where stuff that is deferred to a thread from a LoopingCall is resulting in a DelayedCall ending up in the reactor for the next test. Does that ring any bells?
That can definitely happen. For the time being you probably want to add your own deferToThread layer and have a testCase.addCleanup that makes sure all the relevant Deferreds have fired. -g
participants (2)
-
Chris Withers
-
Glyph