Skip to content

refactor: use ThreadPoolExecutor in extract_all - #60

Merged
henryiii merged 2 commits into
masterfrom
refactor-thread-pool
Aug 6, 2026
Merged

refactor: use ThreadPoolExecutor in extract_all#60
henryiii merged 2 commits into
masterfrom
refactor-thread-pool

Conversation

@henryiii

@henryiii henryiii commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Addresses findings 1 and 2 of #59.

extract_all used a module-level Semaphore that each ExtractionThread acquired in __init__ and that extract_all drained as its join, so a second in-process call deadlocked forever (this is why the test suite needed pytest --forked). A related errors_detected global made mkdoc return silently with exit code 0 on parse failures, so build systems saw success with no output file.

This replaces the Thread/Semaphore machinery with concurrent.futures.ThreadPoolExecutor. Worker exceptions now propagate, so failures exit nonzero, and the globals are gone. pytest-forked and the --forked flag are removed; the suite now runs in a single process.

Beyond CI, the new regression tests were confirmed to fail against the old code: the re-entrancy test hangs, and the exit-code test gets returncode 0.

@henryiii

henryiii commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 AI text below 🤖

All test jobs pass. The "Build distribution" failure is unrelated to this PR: a newly released flit_core emits Metadata-Version: 2.5, which the twine check bundled in build-and-inspect-python-package does not accept yet. Master would fail the same way today (it last passed on Aug 3). A temporary upper bound on flit_core in build-system.requires, or an updated action, will fix it separately.

Replaces the hand-rolled Thread/Semaphore machinery, which permanently
exhausted a module-level semaphore and deadlocked any second call to
extract_all in the same process. Worker exceptions now propagate, so
parse failures exit nonzero instead of silently reporting success.
This also removes the need for pytest --forked.

Addresses findings 1 and 2 of #59.

Assisted-by: ClaudeCode:claude-fable-5
cindex raises if set_library_file/path is called after the library is
loaded, so a second in-process extract_all call failed on platforms
where read_args configures the location. Masked before by pytest
--forked; caught by CI on this branch.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii force-pushed the refactor-thread-pool branch from 45c6a0d to 91b6758 Compare August 6, 2026 02:06
@leakec leakec mentioned this pull request Aug 6, 2026
@leakec
leakec self-requested a review August 6, 2026 17:56
@leakec

leakec commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@henryiii This all looks great to me! I don't have any changes to recommend.

@henryiii
henryiii merged commit 06df284 into master Aug 6, 2026
8 checks passed
@henryiii
henryiii deleted the refactor-thread-pool branch August 6, 2026 17:57
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