stefanw / channels-yroom

Django Channels WebSocket consumer and worker for synchronizing Yjs clients
https://channels-yroom.readthedocs.io/en/latest/
MIT License
15 stars 5 forks source link

Add worker exception handler #10

Closed linspw closed 1 year ago

linspw commented 1 year ago

Maybe it's not the best solution, but believe me it already helps to understand the errors

stefanw commented 1 year ago

Thanks for the feedback! Error handling for the worker is indeed important.

Problem with setting an exception handler on the loop is that in the current implementation the channel consumer is run via channel's ASGI routing which apparently swallows and hangs on exception – at least in the way I used it.

I opened a PR #11 that skips the channel's ASGI routing and runs the consumer directly and then does exception handling similar to how you proposed it. I'll try to come up with tests for exception handling and then I'll merge it.

linspw commented 1 year ago

Great solution you implemented, the worker being linked to ASGI I don't know if it had any gain, but separate seems even better to me.

I will close this PR.