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

Better defaults and better error reporting for incorrect use of state machine #40

Open
philipstarkey opened this issue Apr 25, 2018 · 1 comment
Labels
bug Something isn't working minor

Comments

@philipstarkey
Copy link
Member

Original report (archived issue) by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Generally it would be good to review the state machine API and consider ways of setting default arguments for the case where they're not relevant, for example:

  • create_worker could set primary_worker automatically if primary_worker is not None. That way if there is a single worker, it would already be primary, and if there are multiple workers, the first one created will be primary unless the user specifies otherwise.

  • queue_work could default to using the primary worker if none is specified (this would require changing it to be a keyword argument, but still accepting two positional arguments for backward compat).

  • Some error checking in tab_base_classes.mainloop() regarding workers, so that you get more informative errors than the following (this I suspect is the result of not setting self.primary_worker, meaning it is None):

GetImage.png

The mainloop should be read with a defensive eye to think what could go wrong and how we might provide good defaults and better error messages to minimise mistakes and confusion.

This would make writing new device classes a smoother experience.

@philipstarkey
Copy link
Member Author

Original comment by Philip Starkey (Bitbucket: pstarkey, GitHub: philipstarkey).


We should decide whether the concept of "primary" and "secondary" workers should migrate to Tab (from their existing home in DeviceTab). I'm personally leaning towards keeping it in DeviceTab, in which case a solution would be to reimplement create_worker in DeviceTab with the behaviour you describe (rather than relocating primary_worker to Tab). We could also ensure workers get added to secondary_workers if they are not the primary_worker, however I think that there may be instances where you might want to create a worker and not have it managed by DeviceTab methods so force adding workers to secondary_workers is probably a bad idea.

I think if we automatically set primary_worker then there probably isn't a need to mangle queue_work to change it to accept the worker name as a keyword argument. Of course, up-to-date documentation would go a long way to dealing with these kinds of problems!

More error checking sounds good. I think if we type check worker_process, worker_function, worker_args, and worker_kwargs inside the generator loop (here) then that pretty much covers the common things that will go wrong (anything else going wrong would be the result of pretty severe hacking on the part of the user I think).

@philipstarkey philipstarkey added minor bug Something isn't working labels Apr 5, 2020
Loki27182 pushed a commit to Loki27182/blacs that referenced this issue Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor
Projects
None yet
Development

No branches or pull requests

1 participant