Skip to content

Instantly share code, notes, and snippets.

@cefn
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cefn/edb5d60e87cbffb1a874 to your computer and use it in GitHub Desktop.
Save cefn/edb5d60e87cbffb1a874 to your computer and use it in GitHub Desktop.
from threading import Thread
from time import sleep
from twisted.trial.unittest import TestCase
from twisted.internet.defer import Deferred
from twisted.internet import reactor
class ThreadTestCase(TestCase):
def setUp(self):
pass
def test_delay(self):
messaged = Deferred()
def delaycallback():
sleep(2)
reactor.callFromThread(messaged.callback, True)
Thread(target=delaycallback).start()
return messaged
def tearDown(self):
pass
@cefn
Copy link
Author

cefn commented May 18, 2015

OK, now fixed, with the callFromThread invocation in the right place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment