Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix websocket ping variables issues #1909

Merged
merged 4 commits into from
Sep 28, 2020
Merged

Conversation

brooklet
Copy link

fixed the problem that the websocket ping_timeout and ping_interval parameter settings did not take effect

@brooklet brooklet changed the title fix problem fix websocket ping variables issues Aug 13, 2020
@ahopkins
Copy link
Member

@brooklet Can you take a look at the failing tests?

sanic/server.py Outdated
@@ -955,14 +955,14 @@ def serve(
def _build_protocol_kwargs(
protocol: Type[HttpProtocol], config: Config
) -> dict:
if hasattr(protocol, "websocket_timeout"):
if (dir(protocol).__contains__("websocket_handshake")):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you checking for properties this way? Please avoid using dir() here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted to hasattr, but I might circle back on this to see why we are not using isinstance here, which seems more logical. Do we need duck typing for some reason I am unaware of?

"ping_timeout": config.WEBSOCKET_PING_TIMEOUT,
"ping_interval": config.WEBSOCKET_PING_INTERVAL,
"websocket_max_size": config.WEBSOCKET_MAX_SIZE,
"websocket_max_queue": config.WEBSOCKET_MAX_QUEUE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these being renamed websocket_?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left this change in, but I updated the tests so that the change was carried through consistently.

@ashleysommer
Copy link
Member

@brooklet we want to try to get this merged before the Sanic 2020-09 release. Are you able to make those changes suggested?

@ahopkins ahopkins merged commit 0c4a9b1 into sanic-org:master Sep 28, 2020
@ahopkins ahopkins mentioned this pull request Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants