diff --git a/requirements-frozen.txt b/requirements-frozen.txt index c5b4219..3f7fc62 100644 --- a/requirements-frozen.txt +++ b/requirements-frozen.txt @@ -20,6 +20,6 @@ sanic-routing==0.6.2 typing-extensions==3.10.0.0 ujson==4.0.2 urllib3==1.26.5 -uvloop==0.11.3 +uvloop==0.14.0 websockets==8.1 yarl==1.3.0 diff --git a/requirements.txt b/requirements.txt index ff70ef1..d424716 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ websockets # cli argh -requests +requests \ No newline at end of file diff --git a/run.py b/run.py index 99f8a20..77711c7 100644 --- a/run.py +++ b/run.py @@ -40,6 +40,11 @@ from playhouse.shortcuts import model_to_dict from models import Repo, Job, db, Worker from schedule import always_relaunch, once_per_day +try: + asyncio_all_tasks = asyncio.all_tasks +except AttributeError as e: + asyncio_all_tasks = asyncio.Task.all_tasks + LOGGING_CONFIG_DEFAULTS["loggers"] = { "task": { "level": "INFO", @@ -110,8 +115,7 @@ def datetime_to_epoch_json_converter(o): return o.strftime('%s') -@asyncio.coroutine -def wait_closed(self): +async def wait_closed(self): """ Wait until the connection is closed. @@ -121,7 +125,7 @@ def wait_closed(self): of its cause, in tasks that interact with the WebSocket connection. """ - yield from asyncio.shield(self.connection_lost_waiter) + await asyncio.shield(self.connection_lost_waiter) # this is a backport of websockets 7.0 which sanic doesn't support yet @@ -971,7 +975,7 @@ async def html_index(request): @always_relaunch(sleep=2) async def number_of_tasks(): - print("Number of tasks: %s" % len(Task.all_tasks())) + print("Number of tasks: %s" % len(asyncio_all_tasks())) @app.route('/monitor') @@ -979,7 +983,7 @@ async def monitor(request): snapshot = tracemalloc.take_snapshot() top_stats = snapshot.statistics('lineno') - tasks = Task.all_tasks() + tasks = asyncio_all_tasks() return response.json({ "top_20_trace": [str(x) for x in top_stats[:20]],