Merge pull request #1035 from yunstanford/patch-N
Adopt new websockets interface
This commit is contained in:
commit
1b0ad2c3cd
|
@ -636,7 +636,9 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
||||||
coros = []
|
coros = []
|
||||||
for conn in connections:
|
for conn in connections:
|
||||||
if hasattr(conn, "websocket") and conn.websocket:
|
if hasattr(conn, "websocket") and conn.websocket:
|
||||||
coros.append(conn.websocket.close_connection(force=True))
|
coros.append(
|
||||||
|
conn.websocket.close_connection(after_handshake=True)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,9 @@ class GunicornWorker(base.Worker):
|
||||||
coros = []
|
coros = []
|
||||||
for conn in self.connections:
|
for conn in self.connections:
|
||||||
if hasattr(conn, "websocket") and conn.websocket:
|
if hasattr(conn, "websocket") and conn.websocket:
|
||||||
coros.append(conn.websocket.close_connection(force=True))
|
coros.append(
|
||||||
|
conn.websocket.close_connection(after_handshake=False)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
conn.close()
|
conn.close()
|
||||||
_shutdown = asyncio.gather(*coros, loop=self.loop)
|
_shutdown = asyncio.gather(*coros, loop=self.loop)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -59,7 +59,7 @@ requirements = [
|
||||||
uvloop,
|
uvloop,
|
||||||
ujson,
|
ujson,
|
||||||
'aiofiles>=0.3.0',
|
'aiofiles>=0.3.0',
|
||||||
'websockets>=3.2',
|
'websockets>=4.0',
|
||||||
]
|
]
|
||||||
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
|
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
|
||||||
print("Installing without uJSON")
|
print("Installing without uJSON")
|
||||||
|
|
|
@ -131,5 +131,5 @@ def test_worker_close(worker):
|
||||||
loop.run_until_complete(_close)
|
loop.run_until_complete(_close)
|
||||||
|
|
||||||
assert worker.signal.stopped == True
|
assert worker.signal.stopped == True
|
||||||
conn.websocket.close_connection.assert_called_with(force=True)
|
conn.websocket.close_connection.assert_called_with(after_handshake=False)
|
||||||
assert len(worker.servers) == 0
|
assert len(worker.servers) == 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user