Commit 2cc35ce9 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

now I know how to use asyncio

parent 635ee025
......@@ -24,4 +24,12 @@ def register_out(plugin):
def run():
for proto in in_protocols:
in_proto_insts.append(proto(event_loop))
coros = []
for proto in in_proto_insts:
coros += proto.coros()
for out in out_plugins:
coros += out.coros()
asyncio.gather(coros, loop=event_loop)
event_loop.run_forever()
import asyncio
from collections import defaultdict
from PyIRC.extensions import bot_recommended
from PyIRC.io.asyncio import IRCProtocol
......@@ -67,8 +68,9 @@ class IRC:
netinst = IRCNetwork(**args)
self.network_instances[network] = netinst
coro = netinst.connect()
loop.call_soon(coro)
def coros(self):
return [inst.connect for inst in self.network_instances.values()]
def push(self, project, push):
pass
\ No newline at end of file
......@@ -20,7 +20,9 @@ class HTTPProtocol():
self.server = loop.create_server(self.app.make_handler(),
'0.0.0.0', int(config['http']['port']))
loop.call_soon(self.server)
def coros(self):
return [self.server]
def get_handler(self, request):
"""Handle GET."""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment