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

Solver interrupts do not work correctly if run outside of main thread #901

Open
jtcooper10 opened this issue Dec 19, 2022 · 0 comments
Open
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jtcooper10
Copy link
Collaborator

Currently, the only API really provided for stopping a solver "safely" is to catch a KeyboardInterrupt exception to shut down gracefully. This works well when run directly by users -- e.g. in a Jupyter notebook or Python script -- but causes issues when run in an event loop or on a separate thread due to the fact that signals are only delivered to the main thread.

This means that, if a simulation is run in a job queue like in Dask or on an asyncio event loop, the Python solvers cannot use the pause/resume functionality and the C solvers run the risk of the simulation subprocess not being stopped correctly.

The preferred approach for this would be to expose some sort of job control API so that the lifetime of the simulation can be explicitly managed. The existing run() methods would be intended for user-facing contexts, like Jupyter notebooks, and would simply be a synchronous, KeyboardInterrupt-enabled wrapper around this API.

@jtcooper10 jtcooper10 added the enhancement New feature or request label Dec 19, 2022
@jtcooper10 jtcooper10 added this to the 1.8.0 Release milestone Dec 19, 2022
@jtcooper10 jtcooper10 self-assigned this Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants