Upgrade websockets dependency. (#2154)

* Upgrade websockets dependency.

Fix #2142.

* Bumpt sanic-testing version

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
This commit is contained in:
Aymeric Augustin 2021-06-16 20:49:50 +02:00 committed by GitHub
parent 2c80571a8a
commit aff6604636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -14,9 +14,13 @@ from websockets import ( # type: ignore
ConnectionClosed,
InvalidHandshake,
WebSocketCommonProtocol,
handshake,
)
# Despite the "legacy" namespace, the primary maintainer of websockets
# committed to maintaining backwards-compatibility until 2026 and will
# consider extending it if sanic continues depending on this module.
from websockets.legacy import handshake
from sanic.exceptions import InvalidUsage
from sanic.server import HttpProtocol
@ -126,7 +130,9 @@ class WebSocketProtocol(HttpProtocol):
ping_interval=self.websocket_ping_interval,
ping_timeout=self.websocket_ping_timeout,
)
# Following two lines are required for websockets 8.x
# we use WebSocketCommonProtocol because we don't want the handshake
# logic from WebSocketServerProtocol; however, we must tell it that
# we're running on the server side
self.websocket.is_client = False
self.websocket.side = "server"
self.websocket.subprotocol = subprotocol

View File

@ -88,12 +88,12 @@ requirements = [
uvloop,
ujson,
"aiofiles>=0.6.0",
"websockets>=8.1,<9.0",
"websockets>=9.0",
"multidict>=5.0,<6.0",
]
tests_require = [
"sanic-testing",
"sanic-testing>=0.6.0",
"pytest==5.2.1",
"multidict>=5.0,<6.0",
"gunicorn==20.0.4",

View File

@ -7,7 +7,7 @@ setenv =
{py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
deps =
sanic-testing
sanic-testing>=0.6.0
coverage==5.3
pytest==5.2.1
pytest-cov
@ -18,7 +18,7 @@ deps =
beautifulsoup4
gunicorn==20.0.4
uvicorn
websockets>=8.1,<9.0
websockets>=9.0
commands =
pytest {posargs:tests --cov sanic}
- coverage combine --append