You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@crochet.run_in_reactor lets you easily call into the reactor from another thread. You may, however, have a method that is meant to be async twisted code. It would be nice if you could decorate it in such a way that it raises an exception if you call it in another thread. e.g.
@crochet.run_in_reactordefmeth_to_call_from_threads(self)
d=self.async_code()
d.addCallback(....)
@crochet.ensure_in_reactordefasync_code(self)
# Please raise an error if I am called from outside the reactor.
....
This would catch a case where, e.g. you forget to add the @run_in_reactor decorator to the first method.
The text was updated successfully, but these errors were encountered:
That seems like it might be useful. Care to submit a patch? The changes I just made to @run_in_reactor could work as a basis for this. Otherwise I'll get around to it.
I should note that in general I feel Twisted code should be private, so something like:
@crochet.run_in_reactor
lets you easily call into the reactor from another thread. You may, however, have a method that is meant to be async twisted code. It would be nice if you could decorate it in such a way that it raises an exception if you call it in another thread. e.g.This would catch a case where, e.g. you forget to add the
@run_in_reactor
decorator to the first method.The text was updated successfully, but these errors were encountered: