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

Regions cache (sqlite3) access fails from a forked process #641

Open
randomir opened this issue Jul 23, 2024 · 0 comments
Open

Regions cache (sqlite3) access fails from a forked process #641

randomir opened this issue Jul 23, 2024 · 0 comments
Labels

Comments

@randomir
Copy link
Member

randomir commented Jul 23, 2024

When accessing regions cache (dwave.cloud.regions.get_regions) from multiple processes created by forking, the following error has been reported:

  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/system/samplers/dwave_sampler.py", line 30, in <module>
    from dwave.cloud.client import Client
  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/cloud/__init__.py", line 19, in <module>
    from dwave.cloud.client import Client
  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/cloud/client/__init__.py", line 17, in <module>
    from dwave.cloud.client.base import Client
  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/cloud/client/base.py", line 72, in <module>
    from dwave.cloud.regions import get_regions, resolve_endpoints
  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/cloud/regions.py", line 37, in <module>
    @cached.ondisk(maxage=_REGIONS_CACHE_MAXAGE, key='cache_key', bucket='regions')
  File "/home/wls/.conda/.../lib/python3.9/site-packages/dwave/cloud/utils/decorators.py", line 291, in ondisk
    cache = diskcache.Cache(disk=diskcache.JSONDisk, directory=directory,
  File "/home/wls/.conda/.../lib/python3.9/site-packages/diskcache/core.py", line 478, in __init__
    self.reset(key, value, update=False)
  File "/home/wls/.conda/.../lib/python3.9/site-packages/diskcache/core.py", line 2431, in reset
    ((old_value,),) = sql(
sqlite3.OperationalError: locking protocol

Possible causes:

  • "Under Unix, you should not carry an open SQLite database across a fork() system call into the child process." (source here)
  • Windows accessing sqlite3 file over NFS (see here)
  • DiskCache accessing a file on WSL1
  • this SO answer

See also: #621.

Possibly related: grantjenks/python-diskcache#325, grantjenks/python-diskcache#172.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant