Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pickle related race condition (fixes #1164, fixes #1204) #1243

Merged
merged 1 commit into from
Oct 7, 2024

Commits on Oct 3, 2024

  1. ylib2to3/pgen2/grammar: Fix Grammar.dump for parallel use with Gramma…

    …r.load
    
    Previously, bad timing could make another process run into reading a
    half-written pickle cache file, and thus fail like this:
    
    > Traceback (most recent call last):
    >   File "[..]/bin/yapf", line 5, in <module>
    >     from yapf import run_main
    >   File "[..]/lib/python3.11/site-packages/yapf/__init__.py", line 41, in <module>
    >     from yapf.yapflib import yapf_api
    >   File "[..]/lib/python3.11/site-packages/yapf/yapflib/yapf_api.py", line 38, in <module>
    >     from yapf.pyparser import pyparser
    >   File "[..]/lib/python3.11/site-packages/yapf/pyparser/pyparser.py", line 44, in <module>
    >     from yapf.yapflib import format_token
    >   File "[..]/lib/python3.11/site-packages/yapf/yapflib/format_token.py", line 23, in <module>
    >     from yapf.pytree import pytree_utils
    >   File "[..]/lib/python3.11/site-packages/yapf/pytree/pytree_utils.py", line 30, in <module>
    >     from yapf_third_party._ylib2to3 import pygram
    >   File "[..]/lib/python3.11/site-packages/yapf_third_party/_ylib2to3/pygram.py", line 29, in <module>
    >     python_grammar = driver.load_grammar(_GRAMMAR_FILE)
    >                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >   File "[..]/lib/python3.11/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 252, in load_grammar
    >     g.load(gp)
    >   File "[..]/lib/python3.11/site-packages/yapf_third_party/_ylib2to3/pgen2/grammar.py", line 95, in load
    >     d = pickle.load(f)
    >         ^^^^^^^^^^^^^^
    > EOFError: Ran out of input
    hartwork committed Oct 3, 2024
    Configuration menu
    Copy the full SHA
    51ba17e View commit details
    Browse the repository at this point in the history