Open d33tah opened 3 years ago
Another solution I came up with was to throw an exception and then catch it over process_forever. It's cleaner, but I'm still curious if there's a better way.
One way would be to subclass Reactor and override process_forever
to run until some state changes. Another would be to have your own event loop that calls reactor.process_once
until a certain condition is reached.
I'm trying to write an asynchronous client that's just trying to connect, join a channel, send a message and then quit. I looked at irccat as an example, but I am left with a reactor working while I want the rest of my program to continue outside of that flow. My workaround is that I created a multiprocessing.Process that I then terminate:
Assuming that it's critical for my code to work synchronously and outside of the callback-based model, is there a cleaner way to use the API? Perhaps it would make sense to incorporate it into irccat example instead of doing sys.exit()?