prepare for future change to asyncio.get_event_loop
This commit is contained in:
parent
ea9f64b1b9
commit
eb359ed53b
|
@ -23,7 +23,16 @@ frontend = Path(__file__).resolve().parent.parent.join('http_frontend')
|
||||||
|
|
||||||
class Application:
|
class Application:
|
||||||
def __init__(self, loop=None, views=[], middleware=[], **kwargs):
|
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._server = None
|
||||||
self._tasks = []
|
self._tasks = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue