Closed igel-kun closed 7 years ago
I'm reluctant to see a boolean flag with several touch points. Plus, the change invalidates the docstring and namesake of process_forever. I have another idea.
What about simply writing your own event loop?
import irc.client
import functools
def invoke_while(condition, func):
while condition:
func()
items_to_process = [1, 2, 3]
client = irc.client.SimpleIRCClient()
client.connect(...)
process_once = functools.partial(client.reactor.process_once, timeout=0.2)
invoke_while(items_to_process, process_once)
yeah, I guess that would be better. Alternatively, I could throw some selfmade exception in on_disconnect
I guess... Ok I'll drop the matter, thanks for the hints tho :)
hi, I wanted to use an IRC connection as a subroutine in some code I'm writing, but in all the examples I looked at, whenever the task was done, the program exits via
sys.exit()
which is not an option for me. So I added anactive
flag to theIRC
class that can be set to false to stopprocess_forever()
. Preliminary tests indicate that it's working as intended :)