How would you initialize a worker #2188
Unanswered
morganrallen
asked this question in
Help!
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Howdy folks, I've been using Channels for quite some time now, specifically using workers to maintain and interact with long running background tasks and an issue I've consistently run into is trying to get my workers to initialize when
runworkeris called. In my current project, when a user session starts, a background process is started and detached, it needs to outlive the user session, even if the worker is killed. The session state, pid, etc are tracked in the DB. Now, when a worker starts, I want it to cleanup old sessions by finding everything in the DB that's notEXITED, check if the PID still exists and either revive that or change the status to exited.In the past when I've needed init feature I've just sent a 'run' message shortly after runworker but this is messy and frequently has been unreliable.
I believe this has been brought up in the past but couldn't find any reference (wow that AI search is sure impressive....), so I'm wondering how other folks have handled this. I feel like this should really be a built in feature but think there also might be issues with how ASGI dispatched event. Any insight into other methods would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions