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

Close versus terminate #88

Open
ChriZiegler opened this issue Mar 18, 2021 · 1 comment
Open

Close versus terminate #88

ChriZiegler opened this issue Mar 18, 2021 · 1 comment

Comments

@ChriZiegler
Copy link

Description

I would like to know the difference between Pool.close() and Pool.terminate. The documentation has the following to say:

close() → None
Close the pool to new visitors.

terminate() → None
No running by the pool!

Which is unclear. I thought close would prevent new tasks from being applied, and terminate would stop all currently running tasks, but that doesn't seem to be the case.

@amyreese
Copy link
Member

amyreese commented Mar 19, 2021

This could definitely stand to have better documentation. pool.close() prevents queueing new tasks, and queues commands to the child processes so that they can gracefully stop once the work queue is exhausted, and you can await pool.join() to wait for them to finish. pool.terminate() will immediately terminate (kill -9) those workers, leaving the work queue unfinished, and any pending jobs will be stuck waiting for results, so it should only be used when the service managing the pool must exit immediately without waiting for any in-flight tasks/results.

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

2 participants