mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
Fix AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
This commit is contained in:
parent
19f5bcd000
commit
5572f746ef
1 changed files with 7 additions and 2 deletions
9
run.py
9
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",
|
||||
|
@ -971,7 +976,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 +984,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]],
|
||||
|
|
Loading…
Add table
Reference in a new issue