mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[fix] meh, sanic isn't ready for websockets 7.0
This commit is contained in:
parent
102dec555f
commit
7ba3449fb5
1 changed files with 19 additions and 0 deletions
19
run.py
19
run.py
|
@ -22,6 +22,7 @@ import aiohttp
|
||||||
import aiofiles
|
import aiofiles
|
||||||
|
|
||||||
from websockets.exceptions import ConnectionClosed
|
from websockets.exceptions import ConnectionClosed
|
||||||
|
from websockets import WebSocketCommonProtocol
|
||||||
|
|
||||||
from sanic import Sanic, response
|
from sanic import Sanic, response
|
||||||
from sanic.exceptions import NotFound
|
from sanic.exceptions import NotFound
|
||||||
|
@ -103,6 +104,24 @@ subscriptions = defaultdict(list)
|
||||||
jobs_in_memory_state = {}
|
jobs_in_memory_state = {}
|
||||||
|
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def wait_closed(self):
|
||||||
|
"""
|
||||||
|
Wait until the connection is closed.
|
||||||
|
|
||||||
|
This is identical to :attr:`closed`, except it can be awaited.
|
||||||
|
|
||||||
|
This can make it easier to handle connection termination, regardless
|
||||||
|
of its cause, in tasks that interact with the WebSocket connection.
|
||||||
|
|
||||||
|
"""
|
||||||
|
yield from asyncio.shield(self.connection_lost_waiter)
|
||||||
|
|
||||||
|
|
||||||
|
# this is a backport of websockets 7.0 which sanic doesn't support yet
|
||||||
|
WebSocketCommonProtocol.wait_closed = wait_closed
|
||||||
|
|
||||||
|
|
||||||
def reset_pending_jobs():
|
def reset_pending_jobs():
|
||||||
Job.update(state="scheduled", log="").where(Job.state == "running").execute()
|
Job.update(state="scheduled", log="").where(Job.state == "running").execute()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue