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

[Bug] [Crash][Reproducible] EOFError: Ran out of input when import yapf with multiprocess #1204

Open
whlook opened this issue Feb 27, 2024 · 0 comments

Comments

@whlook
Copy link

whlook commented Feb 27, 2024

previous similar issue #1164

Problems

  • When i use yapf (just import it) in multiprocess program, it will crash with 'EOFError: Ran out of inpu',log info below:

image

Reproduction

  1. yapf==0.40.2
  2. rm -r ~/.cache/YAPF
  3. run this python code:
 import multiprocessing
 
 def proc():
     import yapf
 
 if __name__ == "__main__":
     pp=[]
     for i in range(100):
         p = multiprocessing.Process(target=proc)
         pp.append(p)
 
     for p in pp:
         p.start()
 
     for p in pp:
         p.join()
                                                   

Reason

the problem code is here:

When in multi process enviroment,some process will create grammar cache(when ~/.cache/YAPF not exists), before the process write to the cache file, other process will see the file exist and load it, but the cache file is empty right now , so EOFError will raise and the program crashed.

How to fix it?

@whlook whlook changed the title [Bug] [Crash] EOFError: Ran out of input when import yapf with multiprocess [Bug] [Crash][Reproducible] EOFError: Ran out of input when import yapf with multiprocess Feb 27, 2024
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

No branches or pull requests

1 participant