diff options
author | Nikita Slyusarev <nslus@yandex-team.com> | 2022-02-10 16:46:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:52 +0300 |
commit | cd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch) | |
tree | 1308e0bae862d52e0020d881fe758080437fe389 /library/python/filelock/__init__.py | |
parent | cdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff) | |
download | ydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz |
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 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 f81ff67f37..cdf2ee4f68 100644 --- a/library/python/filelock/__init__.py +++ b/library/python/filelock/__init__.py @@ -1,12 +1,12 @@ -import errno -import logging -import os +import errno +import logging +import os import sys import library.python.windows logger = logging.getLogger(__name__) - + def set_close_on_exec(stream): if library.python.windows.on_win(): @@ -74,19 +74,19 @@ class _WinFileLock(AbstractFileLock): def __init__(self, path): super(_WinFileLock, self).__init__(path) self._lock = None - try: - with file(path, 'w') as lock_file: - lock_file.write(" " * self._LOCKED_BYTES_NUM) - except IOError as e: - if e.errno != errno.EACCES or not os.path.isfile(path): - raise + try: + with file(path, 'w') as lock_file: + lock_file.write(" " * self._LOCKED_BYTES_NUM) + except IOError as e: + if e.errno != errno.EACCES or not os.path.isfile(path): + raise def acquire(self, blocking=True): self._lock = open(self.path) set_close_on_exec(self._lock) import time - locked = False + locked = False while not locked: locked = library.python.windows.lock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) if locked: @@ -97,7 +97,7 @@ class _WinFileLock(AbstractFileLock): return False def release(self): - if self._lock: + if self._lock: library.python.windows.unlock_file(self._lock, 0, self._LOCKED_BYTES_NUM, raises=False) self._lock.close() self._lock = None |