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

Concurrent runs of pyright can result in race condition #318

Open
abelcheung opened this issue Oct 31, 2024 · 0 comments
Open

Concurrent runs of pyright can result in race condition #318

abelcheung opened this issue Oct 31, 2024 · 0 comments

Comments

@abelcheung
Copy link

Following is an excerpt of failure caused by running multiple pyright in subprocesses for first time in Github action:

npm error code EPERM
npm error syscall lstat
npm error path C:\Users\runneradmin\.cache\pyright-python\1.1.386\node_modules\pyright\dist\pyright-internal.js.map
npm error errno -4048
npm error [Error: EPERM: operation not permitted, lstat 'C:\Users\runneradmin\.cache\pyright-python\1.1.386\node_modules\pyright\dist\pyright-internal.js.map'] {
npm error   errno: -4048,
npm error   code: 'EPERM',
npm error   syscall: 'lstat',
npm error   path: 'C:\\Users\\runneradmin\\.cache\\pyright-python\\1.1.386\\node_modules\\pyright\\dist\\pyright-internal.js.map'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It's possible that the file was already in use (by a text editor or antivirus),
npm error or that you lack permissions to access it.
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.

npm error A complete log of this run can be found in: C:\Users\runneradmin\npm-cache\_logs\2024-10-31T17_47_42_564Z-debug-0.log
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\Scripts\pyright.EXE\__main__.py", line 7, in <module>
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\lib\site-packages\pyright\cli.py", line 31, in entrypoint
    sys.exit(main(sys.argv[1:]))
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\lib\site-packages\pyright\cli.py", line 18, in main
    return run(*args, **kwargs).returncode
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\lib\site-packages\pyright\cli.py", line 22, in run
    pkg_dir = install_pyright(args, quiet=None)
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\lib\site-packages\pyright\_utils.py", line 63, in install_pyright
    node.run(
  File "D:\a\types-lxml\types-lxml\.tox\py310-rt-lxml50\lib\site-packages\pyright\node.py", line 144, in run
    subprocess.run(node_args, **kwargs),
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Program Files\\nodejs\\npm.cmd', 'install', '[email protected]']' returned non-zero exit status 4294963248.

This looks like a conflict of multiple invocation of npm install and write into the same cache folder. While end users normally wouldn't call pyright like this, it is quite possible for Github runners where packages are installed anew. For my case it is invoked by tox running multiple test environments in different venv in parallel. The above failure happens sparingly in ubuntu and macos runners, but at high probability for windows runners.

For now I worked around the problem by pre-running pyright once to trigger the install process before running tests. As #300 is not a default for pyright-python, would it be better to be fool-proof by guarding npm install with temp file locking?

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