Skip to content

Commit

Permalink
fix: file lock on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Dec 12, 2024
1 parent e33c0e1 commit b6fd793
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions qiniu/http/regions_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,12 @@ def __init__(self, fd):

def __enter__(self):
try:
# TODO(lihs): set `_nbyte` bigger?
msvcrt.locking(self._fd, msvcrt.LK_LOCK | msvcrt.LK_NBLCK, 1)
msvcrt.locking(self._fd.fileno(), msvcrt.LK_LOCK | msvcrt.LK_NBLCK, 1)
except OSError:
raise FileAlreadyLocked('File {0} already locked'.format(self._file_path))

def __exit__(self, exc_type, exc_val, exc_tb):
msvcrt.locking(self._fd, msvcrt.LK_UNLCK, 1)
msvcrt.locking(self._fd.fileno(), msvcrt.LK_UNLCK, 1)

@property
def _file_path(self):
Expand Down

0 comments on commit b6fd793

Please sign in to comment.