Skip to content

Skip reranker pool teardown during interpreter finalization - #1639

Open
emme1t wants to merge 1 commit into
FlagOpen:masterfrom
emme1t:fix/reranker-pool-shutdown-1414
Open

emme1t wants to merge 1 commit into
FlagOpen:masterfrom
emme1t:fix/reranker-pool-shutdown-1414

Conversation

@emme1t

@emme1t emme1t commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #1414.

The reranker starts daemon workers. Python's multiprocessing exit handler terminates and joins them before late object finalization. Running the ordinary pool and device cleanup again from a late destructor can call into partially cleared modules, as in the reported SIGTERM traceback.

Skip that second cleanup during interpreter finalization. Keep a reference to the finalization check on the destructor itself so it remains available during teardown. Explicit pool shutdown and garbage collection during normal execution still use the existing cleanup path.

The regression test launches a fresh CPython process and holds one reranker until exit. On the parent commit both objects entered pool cleanup. With the change only the normally collected object did.

I also ran the public scoring path on Windows with two spawned CPU workers, then exercised ordinary collection and process exit in separate runs. Both returned scores [3, 4], and all four worker PIDs had exited afterward. These runs exercise the shutdown lifecycle on Windows. The original SIGTERM traceback was reported on Linux.

This branch has not been deployed

No deployments
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.

多线程报错问题

1 participant