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

Simplify Concurrency Design #371

Open
callumforrester opened this issue Feb 7, 2024 · 2 comments
Open

Simplify Concurrency Design #371

callumforrester opened this issue Feb 7, 2024 · 2 comments
Labels
enhancement New feature or request worker Relates to worker code

Comments

@callumforrester
Copy link
Collaborator

Background

At this point, blueapi uses both subprocess and threads manage the concurrent operations of:

  • REST API exposure
  • Management/introspection of RunEngine, plans, devices, etc.
  • Actually running plans

blueapi-subprocess-and-thread(1)

I wonder if this can be simplified.

Proposal

We could ditch the worker thread and make the running of plans block the subprocess. To maintain state querying throughout the running of a plan, we would have to cache state somewhere, possibly in the main process.

blueapi-subprocess-proposal

It's important to add that I don't know if this is actually possible! I don't know if asynchronous updating is supported by subprocess, but it's worth considering.

Would be interested in your thoughts @joeshannon

@callumforrester callumforrester added enhancement New feature or request tests Issues around increasing test coverage/fixing tests worker Relates to worker code and removed tests Issues around increasing test coverage/fixing tests labels Feb 7, 2024
@joeshannon
Copy link
Contributor

There are queues and pipes in the multiprocessing module so I imagine the worker would be able to update the cached state in the API process by putting something onto a queue.

In terms of blocking the subprocess, this would simplify things but do we need any provision for cancelling running plans?

@stan-dot
Copy link
Collaborator

stan-dot commented Mar 8, 2024

what if we use something like redis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request worker Relates to worker code
Projects
None yet
Development

No branches or pull requests

3 participants