-
Notifications
You must be signed in to change notification settings - Fork 462
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
Register the on_error handler #1002
Conversation
if self._input: | ||
await self._input.push_error(ErrorFrame(error)) | ||
if self._output: | ||
await self._output.push_error(ErrorFrame(error)) |
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.
I think it should be more like:
if self._input and self._output:
await self._input.push_error(ErrorFrame(error))
elif self._input:
await self._input.push_error(ErrorFrame(error))
else
await self._output.push_error(ErrorFrame(error))
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.
Or
if (self._input and self._output) or self._input:
await self._input.push_error(ErrorFrame(error))
else
await self._output.push_error(ErrorFrame(error))
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.
What about this?
if self._input is not None:
await self._input.push_error(error_frame)
elif self._output is not None:
await self._output.push_error(error_frame)
else:
logger.error("Both input and output are None while trying to push error")
raise RuntimeError("No valid input or output channel to push error")
Just pushed that.
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.
Ah, yes! That would work. No need for is not None
though.
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.
Approving
ef95ca1
to
6c9c1e1
Compare
LGTM. Just added one nit comment |
6c9c1e1
to
e049ae4
Compare
Please describe the changes in your PR. If it is addressing an issue, please reference that as well.
This PR went stale: #568. I'm doing clean up, so took a quick crack at it. @aconchillo is this along the lines of what you were thinking for the TODO?