Sygil-Dev / whoosh-reloaded

Whoosh is a fast, featureful full-text indexing and searching library implemented in pure Python.
https://sygil-dev.github.io/whoosh-reloaded/
Other
63 stars 12 forks source link

Add no-op for FileLock on Web Assembly Platform #95

Open michaelweinold opened 1 month ago

michaelweinold commented 1 month ago

Would it be possible to add a no-op for the FileLock variable on the Web Assembly platform here:

if os.name == "nt":
    FileLock = MsvcrtLock
else:
    FileLock = FcntlLock

Otherwise, using whoosh in Pyodide will throw an error of the kind:

File /lib/python3.11/site-packages/whoosh/util/filelock.py:100, in FcntlLock.acquire(self, blocking)
     97 flags = os.O_CREAT | os.O_WRONLY
     98 self.fd = os.open(self.filename, flags)
--> 100 mode = fcntl.LOCK_EX
    101 if not blocking:
    102     mode |= fcntl.LOCK_NB

AttributeError: module 'fcntl' has no attribute 'LOCK_EX'

This was suggested here:

and is related to:

github-actions[bot] commented 1 month ago

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.