Skip to content

fix: _NoopThread._started overwrites Thread._started (#130)#131

Closed
LeoLin990405 wants to merge 1 commit intobfly123:mainfrom
LeoLin990405:fix/test-worker-pool-started-attr
Closed

fix: _NoopThread._started overwrites Thread._started (#130)#131
LeoLin990405 wants to merge 1 commit intobfly123:mainfrom
LeoLin990405:fix/test-worker-pool-started-attr

Conversation

@LeoLin990405
Copy link
Contributor

Summary

Fixes #130test_per_session_worker_pool_reuses_same_key fails on all 10 CI jobs (every platform × every Python version).

Root cause

_NoopThread in test/test_worker_pool.py used self._started (a list) as an attribute, which overwrites threading.Thread._started (an internal threading.Event). When PerSessionWorkerPool.get_or_create() calls worker.is_alive(), it triggers self._started.is_set() on a listAttributeError.

Changes

  • Renamed self._startedself.started_keys to avoid collision with Thread._started
  • Added super().start() call so the thread actually starts and is_alive() returns True
  • Added run() with Event.wait() to keep the thread alive during the test
  • Added proper cleanup (stop() + join()) at the end of the test

Test-only change — zero impact on production code.

Test plan

  • pytest test/test_worker_pool.py -v — 3 passed (previously 1 failed, 2 passed)
  • All other tests unaffected

…fly123#130)

_NoopThread used self._started (a list) which overwrites
threading.Thread._started (an Event), breaking is_alive() calls.
Renamed to self.started_keys and made the thread actually start/stay
alive so PerSessionWorkerPool.get_or_create() can correctly detect
live workers.
@bfly123
Copy link
Owner

bfly123 commented Mar 11, 2026

有冲突

@LeoLin990405
Copy link
Contributor Author

Closing this PR — the fix has already been applied on main (using self._track + self._started.set()). Thanks for the heads-up on the conflict!

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.

Bug: test_worker_pool.py CI failure — _NoopThread overwrites Thread._started

2 participants