GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-107219: Fix concurrent.futures terminate_broken() by vstinner · Pull Request #108974 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Sep 6, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fix a race condition in _ExecutorManagerThread.terminate_broken(): ignore the InvalidStateError on future.set_exception(). It can happen if the future is cancelled before the caller.

Moreover, test_crash_big_data() now waits explicitly until the executor completes.

  • Issue: test_concurrent_futures.test_deadlock: test_crash_big_data() hangs randomly on Windows #107219

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-107219: Fix concurrent.futures terminate_broken()
929dea4
Fix a race condition in _ExecutorManagerThread.terminate_broken():
ignore the InvalidStateError on future.set_exception(). It can happen
if the future is cancelled before the caller.

Moreover, test_crash_big_data() now waits explicitly until the
executor completes.
@bedevere-bot bedevere-bot added the awaiting core review label Sep 6, 2023
@bedevere-bot bedevere-bot mentioned this pull request Sep 6, 2023
test_concurrent_futures.test_deadlock: test_crash_big_data() hangs randomly on Windows #107219
Closed
@vstinner vstinner added the skip news label Sep 6, 2023
@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

This change doesn't fix the most annoying bug of issue #107219. test_crash_big_data() still hangs on Windows. But it fix this error:

test_crash_big_data (test.test_concurrent_futures.ProcessPoolSpawnExecutorDeadlockTest.test_crash_big_data) ... Warning -- Uncaugh
t thread exception: InvalidStateError
Exception in thread Thread-9:
Traceback (most recent call last):
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\threading.py", line 1059, in _bootstrap_inner
    self.run()
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\concurrent\futures\process.py", line 344, in run
    self.terminate_broken(cause)
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\concurrent\futures\process.py", line 492, in terminate_broken
    work_item.future.set_exception(bpe)
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\concurrent\futures\_base.py", line 559, in set_exception
    raise InvalidStateError('{}: {!r}'.format(self._state, self))
concurrent.futures._base.InvalidStateError: CANCELLED: <Future at 0x2cf561cf260 state=cancelled>
0.55s Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)
Warning -- Dangling thread: <_MainThread(MainThread, started 11880)>
Warning -- Dangling thread: <Thread(QueueFeederThread, started daemon 4112)>
ok

link: #107219 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

cc @pitrou

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

This change doesn't fix the most annoying bug of issue #107219. test_crash_big_data() still hangs on Windows.

If it wasn't obvious enough, the test decided to hang on Windows x64 CI :-)

0:41:15 load avg: 0.02 [462/462/3] test.test_concurrent_futures.test_deadlock process crashed (Exit code 1)
Timeout (0:20:00)!
Thread 0x00000c90 (most recent call first):
  File "D:\a\cpython\cpython\Lib\multiprocessing\connection.py", line 282 in _send_bytes
  File "D:\a\cpython\cpython\Lib\multiprocessing\connection.py", line 199 in send_bytes
  File "D:\a\cpython\cpython\Lib\multiprocessing\queues.py", line 246 in _feed
  File "D:\a\cpython\cpython\Lib\threading.py", line 996 in run
  File "D:\a\cpython\cpython\Lib\threading.py", line 1059 in _bootstrap_inner
  File "D:\a\cpython\cpython\Lib\threading.py", line 1016 in _bootstrap

Thread 0x00001b78 (most recent call first):
  File "D:\a\cpython\cpython\Lib\threading.py", line 1153 in _wait_for_tstate_lock
  File "D:\a\cpython\cpython\Lib\threading.py", line 1133 in join
  File "D:\a\cpython\cpython\Lib\multiprocessing\queues.py", line 199 in _finalize_join
  File "D:\a\cpython\cpython\Lib\multiprocessing\util.py", line 224 in __call__
  File "D:\a\cpython\cpython\Lib\multiprocessing\queues.py", line 151 in join_thread
  File "D:\a\cpython\cpython\Lib\concurrent\futures\process.py", line 560 in join_executor_internals
  File "D:\a\cpython\cpython\Lib\concurrent\futures\process.py", line 514 in terminate_broken
  File "D:\a\cpython\cpython\Lib\concurrent\futures\process.py", line 344 in run
  File "D:\a\cpython\cpython\Lib\threading.py", line 1059 in _bootstrap_inner
  File "D:\a\cpython\cpython\Lib\threading.py", line 1016 in _bootstrap

Thread 0x000012cc (most recent call first):
  File "D:\a\cpython\cpython\Lib\threading.py", line 1153 in _wait_for_tstate_lock
  File "D:\a\cpython\cpython\Lib\threading.py", line 1133 in join
  File "D:\a\cpython\cpython\Lib\concurrent\futures\process.py", line 843 in shutdown
  File "D:\a\cpython\cpython\Lib\concurrent\futures\_base.py", line 647 in __exit__
  File "D:\a\cpython\cpython\Lib\test\test_concurrent_futures\test_deadlock.py", line 236 in test_crash_big_data
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit a8cae40 into python:main Sep 6, 2023
@vstinner
vstinner deleted the test_concurrent_futures branch September 6, 2023 13:57
@bedevere-bot bedevere-bot removed the awaiting core review label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.