Twisted non-blocking execute reactor.run()?
nonblocking, python, reactor
Solution
`reactor.run()` is a blocking call. You will need to do something like, run your loop in a separate thread. The way you have it, your loop will run, but only if you manage to stop the reactor via some external event or signal. At that time, the call to `reactor.run()` will return, and the remainder of your code will execute.
I am actually looking for a way to call `reactor.run()` in a non-blocking way myself. If anyone has a way to do that, I would love to hear about it.
Problem
I am using twisted reactor to non-block reading sockets input. however, I want to run another loop after reactor starting running ``` ..... reactor.listenTCP(12345, MyFactory()) reactor.run() # ... blah blah socket input related code while 1: ... ... if something: reactor.stop() ``` Problem is after `reactor.run()` the `while` loop will not working. May I know rather than using threading in main `te = Thread(target=reactor.run, args=(False,)).start()`, any other way can make `reactor.run()` working on non-blocking? Thank you.