aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEveldee <eveldee0680@live.fr>2023-05-05 07:31:41 +0200
committerGitHub <noreply@github.com>2023-05-05 11:01:41 +0530
commit45998b3e371b819ce0dbe50da703809a048cc2fe (patch)
treeb82dadac63f0ca285a99d2b6d3b02c8ae88da462
parent2f07c4c1da4361af213e5791279b9d152d2e4ce3 (diff)
downloadhypervideo-pre-45998b3e371b819ce0dbe50da703809a048cc2fe.tar.lz
hypervideo-pre-45998b3e371b819ce0dbe50da703809a048cc2fe.tar.xz
hypervideo-pre-45998b3e371b819ce0dbe50da703809a048cc2fe.zip
[utils] `locked_file`: Fix for virtiofs (#6840)
Authored by: brandon-dacrib Closes #6823
-rw-r--r--yt_dlp/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 2f5e66720..47aa75c47 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -2187,10 +2187,11 @@ else:
fcntl.lockf(f, flags)
def _unlock_file(f):
- try:
- fcntl.flock(f, fcntl.LOCK_UN)
- except OSError:
- fcntl.lockf(f, fcntl.LOCK_UN)
+ with contextlib.suppress(OSError):
+ return fcntl.flock(f, fcntl.LOCK_UN)
+ with contextlib.suppress(OSError):
+ 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: