Skip to content

bpo-31530: stop crashes when iterating over a file on multiple threads - #3670

Closed
benjaminp wants to merge 1 commit into
2.7from
benjamin-iteration-torture
Closed

benjaminp wants to merge 1 commit into
2.7from
benjamin-iteration-torture

Conversation

@benjaminp

@benjaminp benjaminp commented Sep 20, 2017 •

Copy link
Copy Markdown
Contributor

Multiple threads iterating over a file can corrupt the file's internal readahead
buffer resulting in crashes. To fix this, cache buffer state thread-locally for
the duration of a file_iternext call and only update the file's internal state
after reading completes.

No attempt is made to define or provide "reasonable" semantics for iterating
over a file on multiple threads. (Non-crashing) races are still
present. Duplicated, corrupt, and missing data will happen.

https://bugs.python.org/issue31530

Multiple threads iterating over a file can corrupt the file's internal readahead
buffer resulting in crashes. To fix this, cache buffer state thread-locally for
the duration of a file_iternext call and only update the file's internal state
after reading completes.

No attempt is made to define or provide "reasonable" semantics for iterating
over a file on multiple threads. (Non-crashing) races are still
present. Duplicated, corrupt, and missing data will happen.
@vstinner

Copy link
Copy Markdown
Member

I'm not sure that I like this approach. See the discussion on the issue: https://bugs.python.org/issue31530#msg302932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants