prepare for future change to asyncio.get_event_loop

This commit is contained in:
Izalia Mae 2021-10-26 18:21:49 -04:00
parent ea9f64b1b9
commit eb359ed53b

View file

@ -23,7 +23,16 @@ frontend = Path(__file__).resolve().parent.parent.join('http_frontend')
class Application:
def __init__(self, loop=None, views=[], middleware=[], **kwargs):
self.loop = loop or asyncio.get_event_loop()
if loop:
self.loop = loop
else:
try:
self.loop = asyncio.get_running_loop()
except RuntimeError:
self.loop = asyncio.new_event_loop()
self._server = None
self._tasks = []