-
Notifications
You must be signed in to change notification settings - Fork 189
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
disconnect gracefully in an unexpected exit #345
Conversation
hangups/client.py
Outdated
if self._listen_future._exception is not None: | ||
logger.info('disconnect: discard %s', | ||
repr(self._listen_future._exception)) | ||
self._client._listen_future._exception = None |
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.
To avoid the protected access, could we instead call self._listen_future.result()
and catch the 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.
A broad except is needed then. dde895c solves this without a raised Exception.
this allows further usage of the connector after the long-polling-request returned
A |
The fix in 1348c20 has a hardcoded delay of |
Could we cancel the task instead of waiting for it to complete? The UI can start some other tasks as well. As a more general solution, could we keep track of them all and cancel each one on exit? This patch also seems to work for turning |
The loop will likely stop before the cleanup of resources used inside the tasks finished and If the sequence of completion does not matter,
The diff works great for the |
Is that a problem if we re-start the loop and wait for the cancelled tasks to finish?
I'd actually prefer unexpected exceptions to exit hangups and print a traceback. That makes it obvious when there's a bug. |
re-start at which point? multiple
Ok. The traceback of the raised low-level Exception will reach the terminal and hangups will exit, but the Exceptions or resource warnings this forceful exit would result in, will not be raised as we wait for and close the resources graceful in the recent commits. |
5f9067e
to
34cff59
Compare
Started working on another approach in #378. |
Superseded by #378. |
The UI currently does not cancel the long-polling request on an unexpected error, for example a
SystemExit
orKeyboardInterrupt
seen in #336.The cleanup is then done by the garbage collector of python, which does not play nice with
asyncio
.Running
hangups.client.Client.disconnect
would raise theKeyboardInterrupt
orSystemExit
again, we need to discard a raisedException
manually.