[Twisted-Python] reactor.run hangs

Alexandre Quessy alexandre at quessy.net
Sun Feb 14 22:30:36 MST 2010


Hello giskard,
I suggest you leave the reactor.run() in the if __name__ == "__main__"
of your application. It's a blocking call, until you call
reactor.stop().
Thats make things a lot easier when you need to merge many
applications, classes, etc. together.

Next, to start your Jabber client, you should probably do it when
reactor is running. To do so, you can use a reactor.callLater.

if __name__ == "__main__":
  def _later():
    # do stuff
  reactor.callLater(0, _later)
  reactor.run()


2010/2/14 Darren Govoni <darren at ontrenet.com>:
> I believe reactor.run() never returns and always blocks the calling thread
> until reactor.stop() is called, afterwhich you cannot call reactor.run()
> again. Not sure if that helps you though.
>
> On Sun, 2010-02-14 at 22:36 +0100, giskard wrote:
>
> Hi all,
>
> i think i'm not doing things in the right way:
>
> http://paste.debian.net/59855/
>
> this code implement a simple jabber client, if you remove the class
> defnition
> and run it (removing also the run def) it works!
>
> but if i 'class' it and run via:
> http://paste.debian.net/59856/
>
> reactor.run() hangs.
>
> where i'm wrong?
>
> thank you in advance,
> --
> ciao,
> giskard
>
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>



-- 
Alexandre Quessy
http://alexandre.quessy.net/




More information about the Twisted-Python mailing list