-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add WebsocketServer exception handler #31
Conversation
82c8103
to
37b96c1
Compare
pycrdt_websocket/websocket_server.py
Outdated
# wait forever | ||
self._task_group.start_soon(Event().wait) | ||
break | ||
except Exception as e: |
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.
When the original task group fail, all its tasks are cancelled, including all the existing rooms's broadcast_update tasks, do we need to find a way to recover them?
Is it possible to have one task group per room so one room throws exception in broadcast_update task won't also tear down other room's broadcast_update task?
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.
Could we also add auto_restart for yroom's task group as well?
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 we should explore recovering each individual room too, but maybe let's leave this for a follow-up PR?
At the very minimum we need recovery at the top layer.
This looks good to me @davidbrochart. |
37b96c1
to
0d60753
Compare
421872a
to
8b7f664
Compare
8b7f664
to
61cf47f
Compare
I removed There are two places where exceptions can be handled:
The WebSocket server task group is re-created upon successful exception handling, so that it always stays alive. |
I like this a lot, @davidbrochart. Great work! |
this looks good, @davidbrochart. I propose we merge here and work on getting #30 to follow this pattern. If we notice any changes needed here in that PR, we can fix there. I'll work with @jzhang20133 to get these two aligned. |
Sounds good. |
The ability to auto-restart is only supported when using the start/stop API for now, not the context manager.
It does so by catching exceptions and re-creating a new task group.