diff options
author | exprmntr <exprmntr@yandex-team.ru> | 2022-02-10 16:46:50 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:50 +0300 |
commit | a6396ea4e82c2605dcf9a11ebc4c289d0b1c734c (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/python/filelock/__init__.py | |
parent | 078ddb2fb76387cae14e8c3ceb5a896009a5a539 (diff) | |
download | ydb-a6396ea4e82c2605dcf9a11ebc4c289d0b1c734c.tar.gz |
Restoring authorship annotation for exprmntr <exprmntr@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/filelock/__init__.py')
-rw-r--r-- | library/python/filelock/__init__.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/library/python/filelock/__init__.py b/library/python/filelock/__init__.py index b68c1d7426..f81ff67f37 100644 --- a/library/python/filelock/__init__.py +++ b/library/python/filelock/__init__.py @@ -3,19 +3,19 @@ import logging import os import sys -import library.python.windows +import library.python.windows logger = logging.getLogger(__name__) -def set_close_on_exec(stream): - if library.python.windows.on_win(): - library.python.windows.set_handle_information(stream, inherit=False) - else: - import fcntl - fcntl.fcntl(stream, fcntl.F_SETFD, fcntl.FD_CLOEXEC) - - +def set_close_on_exec(stream): + if library.python.windows.on_win(): + library.python.windows.set_handle_information(stream, inherit=False) + else: + import fcntl + fcntl.fcntl(stream, fcntl.F_SETFD, fcntl.FD_CLOEXEC) + + class AbstractFileLock(object): def __init__(self, path): @@ -83,12 +83,12 @@ class _WinFileLock(AbstractFileLock): def acquire(self, blocking=True): self._lock = open(self.path) - set_close_on_exec(self._lock) + set_close_on_exec(self._lock) import time locked = False while not locked: - locked = library.python.windows.lock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) + locked = library.python.windows.lock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) if locked: return True if blocking: @@ -98,7 +98,7 @@ class _WinFileLock(AbstractFileLock): def release(self): if self._lock: - library.python.windows.unlock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) + library.python.windows.unlock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) self._lock.close() self._lock = None |