Skip to content

Commit

Permalink
[utils] locked_file: Fix for virtiofs (#6840)
Browse files Browse the repository at this point in the history
Authored by: brandon-dacrib
Closes #6823
  • Loading branch information
Eveldee committed May 5, 2023
1 parent 2f07c4c commit 45998b3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions yt_dlp/utils.py
Expand Up @@ -2187,10 +2187,11 @@ def _lock_file(f, exclusive, block):
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:

Expand Down

0 comments on commit 45998b3

Please sign in to comment.