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

Provide better facilities or patterns for service cleanup #452

Open
mdickinson opened this issue Oct 21, 2021 · 0 comments
Open

Provide better facilities or patterns for service cleanup #452

mdickinson opened this issue Oct 21, 2021 · 0 comments

Comments

@mdickinson
Copy link
Member

Envisage services often require some form of cleanup. For example, if a plugin offers a service that provides a pool of worker threads, those worker threads should typically be shut down before process exit.

Currently there don't seem to be clean patterns for doing this, and there are some pitfalls with current common approaches. One common pattern has the service object - e.g., the ThreadPoolExecutor for the above example - as a trait on the plugin that offers the service, and then uses the plugin's stop method to shut down the executor. But if using Traits defaults, it's easy to write this in such a way that the executor is accidentally started (and then stopped) during the stop method. That's merely inefficient, but for more complicated things, trying to start a service during application shutdown may not work at all.

There may be ways that Envisage can be improved here. Failing that, we can at least document possible approaches and their pitfalls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant