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

Log if closing an executor is not possible in thread #6644

Merged
merged 2 commits into from
Jun 29, 2022

Conversation

fjetter
Copy link
Member

@fjetter fjetter commented Jun 28, 2022

This should only happen if the process is actually tearing down. If we hit this exception for any other reason, I would like to know

@@ -1556,6 +1556,11 @@ def _close():
try:
await to_thread(_close)
except RuntimeError: # Are we shutting down the process?
logger.error(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some information to the log message saying that this error is okay when we are shutting down the process? Otherwise, people might be confused to see an error log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the logic. If python is shutting down, we're calling close immediately without trying to dispatch to the asyncio threadpool.
In all other cases, we'll try the dispatch and log this error when calling it explicitly.

This way we

  • do not spam warnings for ordinary shutdown
  • do not block for threads when the interpreter shuts down
  • log an error if something happens we actually do not anticipate

this code is obviously much more verbose but encodes our intentions better.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 2022

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       15 files  ±0         15 suites  ±0   10h 45m 9s ⏱️ + 27m 0s
  2 898 tests ±0    2 811 ✔️  - 1    83 💤 +1  4 ±0 
21 467 runs  +1  20 499 ✔️ +2  963 💤  - 2  5 +1 

For more details on these failures, see this check.

Results for commit 272ee14. ± Comparison against base commit 40c9420.

♻️ This comment has been updated with latest results.

await to_thread(_close)
except RuntimeError: # Are we shutting down the process?
_close() # Just run it directly
if is_python_shutting_down():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is neat!

@fjetter fjetter merged commit ed36d80 into dask:main Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants