mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[fix] attemp to remove maybe dead websockets tasks that could memleaks
This commit is contained in:
parent
ed6d7cf1c7
commit
ae8a5a40bd
1 changed files with 24 additions and 8 deletions
32
run.py
32
run.py
|
@ -512,8 +512,12 @@ async def ws_index(request, websocket):
|
||||||
}))
|
}))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# do nothing with input but wait
|
# ping periodically to remove dead connections
|
||||||
await websocket.recv()
|
try:
|
||||||
|
await websocket.send("ping")
|
||||||
|
except ConnectionClosed:
|
||||||
|
return
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
@app.websocket('/job-<job_id>-ws')
|
@app.websocket('/job-<job_id>-ws')
|
||||||
|
@ -533,8 +537,12 @@ async def ws_job(request, websocket, job_id):
|
||||||
}))
|
}))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# do nothing with input but wait
|
# ping periodically to remove dead connections
|
||||||
await websocket.recv()
|
try:
|
||||||
|
await websocket.send("ping")
|
||||||
|
except ConnectionClosed:
|
||||||
|
return
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
@app.websocket('/apps-ws')
|
@app.websocket('/apps-ws')
|
||||||
|
@ -631,8 +639,12 @@ async def ws_apps(request, websocket):
|
||||||
}))
|
}))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# do nothing with input but wait
|
# ping periodically to remove dead connections
|
||||||
await websocket.recv()
|
try:
|
||||||
|
await websocket.send("ping")
|
||||||
|
except ConnectionClosed:
|
||||||
|
return
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
@app.websocket('/app-<app_name>-ws')
|
@app.websocket('/app-<app_name>-ws')
|
||||||
|
@ -650,8 +662,12 @@ async def ws_app(request, websocket, app_name):
|
||||||
}))
|
}))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# do nothing with input but wait
|
# ping periodically to remove dead connections
|
||||||
await websocket.recv()
|
try:
|
||||||
|
await websocket.send("ping")
|
||||||
|
except ConnectionClosed:
|
||||||
|
return
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
def require_token():
|
def require_token():
|
||||||
|
|
Loading…
Add table
Reference in a new issue