Skip to content

Commit af509de

Browse files
committed
Fix the fact that the timeout parameter was not getting passed
A breaking change in tox-dev/filelock#345 cause the locks to hang
1 parent 6617fc7 commit af509de

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

multiuserfilelock/__init__.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
tmpdir = Path(tempfile.gettempdir())
3131

3232

33-
class MultiUserFileLock(FileLock):
33+
class MultiUserFileLock:
3434
def __init__(self, *args, user=None, group=None, chmod=0o666, **kwargs):
3535
if os.name == 'nt':
3636
self._user = None
@@ -45,8 +45,8 @@ def __init__(self, *args, user=None, group=None, chmod=0o666, **kwargs):
4545

4646
# Will create a ._lock_file object
4747
# but will not create the files on the file system
48-
super().__init__(*args, **kwargs)
49-
self._lock_file_path = Path(self.lock_file)
48+
self._filelock = FileLock(*args, **kwargs)
49+
self._lock_file_path = Path(self._filelock.lock_file)
5050
parent = self._lock_file_path.parent
5151
# Even though the "other write" permissions are enabled
5252
# it seems that the operating systems disables that for the /tmp dir
@@ -60,7 +60,7 @@ def __init__(self, *args, user=None, group=None, chmod=0o666, **kwargs):
6060
shutil.chown(parent, user=self._user)
6161

6262
def acquire(self, *args, **kwargs):
63-
super().acquire(*args, **kwargs)
63+
self._filelock.acquire(*args, **kwargs)
6464
# once the lock has been acquired, we are more guaranteed that the
6565
# _lock_file exists
6666
if self._chmod:
@@ -83,6 +83,41 @@ def acquire(self, *args, **kwargs):
8383
if self._lock_file_path.owner() != self._user:
8484
shutil.chown(self._lock_file_path, user=self._user)
8585

86+
@property
87+
def is_locked(self):
88+
return self._filelock.is_locked
89+
90+
def release(self, *args, **kwargs):
91+
self._filelock.release(*args, **kwargs)
92+
93+
def __enter__(self):
94+
self.acquire()
95+
return self
96+
97+
def __exit__(self, *args, **kwargs):
98+
self.release()
99+
100+
101+
@property
102+
def timeout(self):
103+
return self._filelock.timeout
104+
105+
@timeout.setter
106+
def timeout(self, value):
107+
self._filelock.timeout = value
108+
109+
@property
110+
def blocking(self):
111+
return self._filelock.blocking
112+
113+
@blocking.setter
114+
def blocking(self, value):
115+
self._filelock.blocking = value
116+
117+
@property
118+
def lock_file(self):
119+
return self._filelock.lock_file
120+
86121

87122
__all__ = [
88123
'MultiUserFileLock',

0 commit comments

Comments
 (0)