Skip to content

Keep igzip_threaded workers running after the opening thread ends - #320

Open
ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:threaded-main-thread
Open

ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:threaded-main-thread

Conversation

@ptweezy

@ptweezy ptweezy commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

When the thread that opened an igzip_threaded file ends, for example a ThreadPoolExecutor thread after shutdown(), reads return truncated data without an error, and write() and close() wait forever. The worker threads stop when the opening thread is not alive, a check that 1.7.1 added so that an unclosed file does not block exit. They now keep running while the opening thread or the main thread is alive. At exit, Python marks the main thread stopped before it waits for the other threads, so the 1.7.1 case still exits. test_threaded_reader_opened_in_finished_thread and test_threaded_writer_opened_in_finished_thread fail on develop.

One narrow case gets worse: on Python 3.13 and later, destroying a legacy subinterpreter waits forever when a file that an ended thread in it opened is still open. Develop already waits forever there for files opened by the thread that runs the subinterpreter.

Checklist

  • Pull request details were added to CHANGELOG.rst
  • Documentation was updated (if needed)

The workers stopped when the thread that called open() ended. Reads then
returned truncated data and writes waited forever. Now they stop only
when the main thread has ended too, which still lets Python exit with an
unclosed file.

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