[Twisted-Python] running code on its own and importing, howto install a different reactor?

meejah meejah at meejah.ca
Fri Jul 29 13:59:00 MDT 2016


steven meier <commercials24 at yahoo.de> writes:

> if __name__ == '__main__':
>     import qt5reactor
>     qt5reactor.install()
>     from twisted.internet import reactor
>     reactor.callWhenRunning(print_it, reactor)
>     reactor.run()

For "client-style" things (I guess I just mean "something that exits"),
there's even a utility function that calls some method you provide with
the reactor as the first argument, and arranges for reactor.stop() to
get called exactly once (when the Deferred returned by your method
fires).

    import qt5reactor
    qt5reactor.install()
    from twisted.internet.task import react

    if __name__ == '__main__':
        react(print_it)

-- 
meejah




More information about the Twisted-Python mailing list