0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-12-01 03:43:02 +00:00

[utils] locked_file: Fix for virtiofs (#6840)

Authored by: brandon-dacrib
Closes #6823
This commit is contained in:
Eveldee 2023-05-05 07:31:41 +02:00 committed by GitHub
parent 2f07c4c1da
commit 45998b3e37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2187,10 +2187,11 @@ def _lock_file(f, exclusive, block):
fcntl.lockf(f, flags) fcntl.lockf(f, flags)
def _unlock_file(f): def _unlock_file(f):
try: with contextlib.suppress(OSError):
fcntl.flock(f, fcntl.LOCK_UN) return fcntl.flock(f, fcntl.LOCK_UN)
except OSError: with contextlib.suppress(OSError):
fcntl.lockf(f, fcntl.LOCK_UN) return fcntl.lockf(f, fcntl.LOCK_UN) # AOSP does not have flock()
return fcntl.flock(f, fcntl.LOCK_UN | fcntl.LOCK_NB) # virtiofs needs LOCK_NB on unlocking
except ImportError: except ImportError: