-
Notifications
You must be signed in to change notification settings - Fork 94
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
Calling publisher coroutine from another thread #3564
Comments
The publisher doesn't need to be in lock-step, |
After working on #3654 I'm keen that we stop spawning/managing threads in the add-hoc way we currently do (I've hit all sorts of lovely issues). As of #3654 the Scheduler is "event loop agnostic", it gets executed in a single loop provided by the executor. How about re-working the server/publisher code to be async and, if possible, agnostic to the async implementation (plus or minus a couple of |
Yeah, we can do this, but we needed to change the socket.recv loop to the no-wait version otherwise it will cause the whole program to hang. |
And actually, I think the publisher is already in a state that it can run in the same thread... The ZMQ authenticator still runs in it's own thread (which is fine) |
While reviewing #3492 I noticed the publisher was being called differently.
I had a closer look after re-basing a branch and realised the publisher is running in a different thread, and awaiting the
publish
coroutine from the main thread:cylc-flow/cylc/flow/scheduler.py
Lines 1608 to 1609 in e904325
This isn't desirable (although may not be an issue):
https://docs.python.org/3/library/asyncio-dev.html#concurrency-and-multithreading
So, to be safe, we have two options here:
loop.call_soon_threadsafe()
).publisher.py
has no blocking calls or loops (unlike the REQ/RESserver.py
), we could run the publisher in the main thread and keep the awaited publish the same.In my opinion, and assuming publishing is not that intensive/blocking; we should go with option 2, as it simplifies the workflow scheduler somewhat (if extra thread isn't needed, why use it).
Thoughts? (ping @oliver-sanders)
Pull requests welcome!
The text was updated successfully, but these errors were encountered: