Skip to content

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

Merged
fjetter merged 2 commits into
dask:mainfrom
fjetter:add_error_log_for_thread_dispatching
Jun 29, 2022
Merged

fjetter merged 2 commits into
dask:mainfrom
fjetter:add_error_log_for_thread_dispatching

Conversation

@fjetter

@fjetter fjetter commented Jun 28, 2022

Copy link
Copy Markdown
Member

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

Comment thread distributed/worker.py Outdated
try:
await to_thread(_close)
except RuntimeError: # Are we shutting down the process?
logger.error(

Copy link
Copy Markdown
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
Copy Markdown
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

github-actions Bot commented Jun 28, 2022 •

Copy link
Copy Markdown
Contributor

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.

Comment thread distributed/worker.py
await to_thread(_close)
except RuntimeError: # Are we shutting down the process?
_close() # Just run it directly
if is_python_shutting_down():

Copy link
Copy Markdown
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