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

Locks of one user prevent other users from loading the same compiler versions #155

Open
gsalzer opened this issue Dec 14, 2022 · 0 comments

Comments

@gsalzer
Copy link

gsalzer commented Dec 14, 2022

Environment information

  • py-solc-x Version: 1.1.1
  • OS: linux

What was wrong?

When downloading a compiler, py-solc-x acquires a lock for a file named /tmp/.solcx-lock-XXX, where XXX is the solc version currently processed. The lock file remains even after releasing the lock and finishing the program that uses py-solc-x (which is how fctl locks are supposed to work). However, when another user performs a similar operation resulting in the same lock file id (e.g., loading the same solc version), this operation will fail, as the lock file already exists, but is owned by the former user.

How can it be fixed?

Add the user id to the name of the lock file. In py-solc-x/solcx/utils/lock.py, the following changes are required.

  1. Import the package getpass.

    import getpass
  2. Replace the line

         self._lock_path = Path(tempfile.gettempdir()).joinpath(f".solcx-lock-{lock_id}")

    (in _ProcessLock.__init__, currently line 39) by

         self._lock_path = Path(tempfile.gettempdir()).joinpath(f".solcx-lock-{getpass.getuser()}-{lock_id}")
gsalzer added a commit to gsalzer/py-solc-x that referenced this issue Dec 14, 2022
gsalzer added a commit to smartbugs/py-solc-x that referenced this issue Dec 14, 2022
Locks acquired by one user when downloading a compiler will prevent other users from doing the same, because the name of the lock file depends only on the solc version, but not on the user id, and the lock file is owned by the first user.
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