-
Notifications
You must be signed in to change notification settings - Fork 310
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 connection exception cause high cpu load #1484
base: main
Are you sure you want to change the base?
fix connection exception cause high cpu load #1484
Conversation
adjust err log
@@ -147,6 +147,9 @@ def handle_incoming_message(self, message: str) -> None: | |||
"""Send message to gateway server.""" | |||
if self.ws is None and self.ws_future is not None: | |||
loop = IOLoop.current() | |||
if self.ws_future.done(): | |||
self.log.error(f"Exception connect to gateway server {self.ws_future.exception()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future.done()
does not imply that it failed, whereas log message assumes it has.
Maybe the fix here is to add and not self.ws_future.done()
to the condition on line 148? Or more lkely, the ws future error was already logged, and the right thing to do here is a debug (or warning, I'm not sure)-log for "message on closed websocket"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,you are right,I adjust it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe like this
if self.ws_future.done() and isinstance(self.ws_future.exception(), Exception):
self.log.error(f"Exception connect to server {self.ws_future.exception()}")
return
if use if self.ws is None and not self.ws_future.done()
when raise connection err,code will execute else logic self._write_message(message)
@@ -146,6 +146,9 @@ def handle_outgoing_message(self, incoming_msg: str, *args: Any) -> None: | |||
def handle_incoming_message(self, message: str) -> None: | |||
"""Send message to gateway server.""" | |||
if self.ws is None and self.ws_future is not None: | |||
if self.ws_future.done() and isinstance(self.ws_future.exception(), Exception): | |||
self.log.warning(f"Exception connect to websocket {self.ws_future.exception()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.log.warning(f"Exception connect to websocket {self.ws_future.exception()}") | |
self.log.warning(f"Exception connecting to websocket {self.ws_future.exception()}") |
if self.ws_future.done() and isinstance(self.ws_future.exception(), Exception): | ||
self.log.warning(f"Exception connect to websocket {self.ws_future.exception()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only log the Exception here if an exception in ws_future
wouldn't already be logged, but it is. How about a simpler:
if self.ws_future.done() and isinstance(self.ws_future.exception(), Exception): | |
self.log.warning(f"Exception connect to websocket {self.ws_future.exception()}") | |
if self.ws_future.done() and self.ws_future.exception() is not None: | |
self.log.warning("Ignoring message on failed connection to kernel %s", self.kernel_id) |
fix #1483