Skip to content
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

co_main hangs for long-running, detached tasks #72

Closed
anarthal opened this issue Aug 14, 2023 · 6 comments
Closed

co_main hangs for long-running, detached tasks #72

anarthal opened this issue Aug 14, 2023 · 6 comments

Comments

@anarthal
Copy link

If you spawn a long-running, detached task (like a websocket session), SIGINT won't cancel it, but co_main will wait for it, causing a deadlock.

@klemens-morgenstern
Copy link
Collaborator

You co_await it ?

@anarthal
Copy link
Author

It's detached, so, no.

@klemens-morgenstern
Copy link
Collaborator

That's by design then. SIGINT & SIGTERM send cancellation signals to main, not to everything.

@anarthal
Copy link
Author

But co_main does wait for all tasks to finish, detached or not. That's calling for deadlocks.

@klemens-morgenstern
Copy link
Collaborator

I'll check if I can wire up detached tasks to a global cancellation thing so they can get signalled.

My idea was that you don't detach, but use wait_group et al.

@klemens-morgenstern
Copy link
Collaborator

I think the approach is correct. It's akin to a main creating & detaching threads, which won't be stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants