[Twisted-Python] Run Twisted reactor from a Thread
dw+twisted-python at hmmz.org
dw+twisted-python at hmmz.org
Tue Feb 3 08:23:56 MST 2015
If you can, check out Crochet. It wraps up most of the mess involved in
making this work, and vastly simpliies the experience..
http://crochet.readthedocs.org/en/latest/
David
On Tue, Feb 03, 2015 at 03:41:17PM +0100, Abdelhalim Kadi wrote:
> Hello;
>
>
> When i run reactor from thread in a synchrone python program, the twisted code
> is never called.
>
> To resolve this problem, I had to put a sleep.
>
> def _reactor_thread(self):
> if not self.reactor.running:
> self.reactor.run(installSignalHandlers=0)
>
>
> def _start_thread( self ):
>
> self.client_thread = Thread( target=self._reactor_thread,
> name="mine" )
> self.client_thread.setDaemon(True)
> self.client_thread.start()
> from time import sleep
> sleep( 0.5 )
>
> What is the best way to do it, instead of calling sleep?
>
>
> Thank you.
>
>
> Abdel Halim
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list