tox-dev / filelock

A platform-independent file lock for Python.
https://py-filelock.readthedocs.io
The Unlicense
745 stars 107 forks source link

Android/Termux doesn't have flock, use lockf, SoftFileLock, or no lock? #349

Open Leif-W opened 2 months ago

Leif-W commented 2 months ago

Similar issue as listed on yt-dlp.

Android/Termux doesn't have flock. Fallback to lockf or SoftFileLock? Possibly fallback to no lock?

scdl shown in example uses filelock as a dependency, yt-dlp rolls their own.

filelock's _unix.py incorrectly assumes all Unices have flock, or that Android === Unix.

Note: command line for example only

scdl -l https://soundcloud.com/user/track
Soundcloud Downloader
Found a track
Downloading track
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_unix.py", line 46, in _acquire
    fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
OSError: [Errno 38] Function not implemented

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/scdl", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 304, in main
    download_url(client, **python_args)
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 409, in download_url
    download_track(client, item, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 887, in download_track
    with lock:
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_api.py", line 376, in __enter__
    self.acquire()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_api.py", line 332, in acquire
    self._acquire()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_unix.py", line 51, in _acquire
    raise NotImplementedError(msg) from exception
NotImplementedError: FileSystem does not appear to support flock; use SoftFileLock instead
DJStompZone commented 1 month ago

This error is driving me nuts

"Use softfilelock instead" Ok yes but HOW??