aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/filelock/__init__.py
diff options
context:
space:
mode:
authorexprmntr <exprmntr@yandex-team.ru>2022-02-10 16:46:50 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:50 +0300
commit078ddb2fb76387cae14e8c3ceb5a896009a5a539 (patch)
treedda2d61bf8f818c76b5602b79366b5fcbcf2e479 /library/python/filelock/__init__.py
parent5085152b94bf621933243a498def7f37d2e76b58 (diff)
downloadydb-078ddb2fb76387cae14e8c3ceb5a896009a5a539.tar.gz
Restoring authorship annotation for exprmntr <exprmntr@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/filelock/__init__.py')
-rw-r--r--library/python/filelock/__init__.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/library/python/filelock/__init__.py b/library/python/filelock/__init__.py
index f81ff67f37..b68c1d7426 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