@@ -82,8 +82,8 @@ class BaseFileLock(ABC, contextlib.ContextDecorator):
82
82
def __new__ ( # noqa: PLR0913
83
83
cls ,
84
84
lock_file : str | os .PathLike [str ],
85
- timeout : float = - 1 , # noqa: ARG003
86
- mode : int = 0o644 , # noqa: ARG003
85
+ timeout : float = - 1 ,
86
+ mode : int = 0o644 ,
87
87
thread_local : bool = True , # noqa: ARG003, FBT001, FBT002
88
88
* ,
89
89
is_singleton : bool = False ,
@@ -97,6 +97,9 @@ def __new__( # noqa: PLR0913
97
97
if not instance :
98
98
instance = super ().__new__ (cls )
99
99
cls ._instances [str (lock_file )] = instance
100
+ elif timeout != instance .timeout or mode != instance .mode :
101
+ msg = "Singleton lock instances cannot be initialized with differing arguments"
102
+ raise ValueError (msg )
100
103
101
104
return instance # type: ignore[return-value] # https://github.com/python/mypy/issues/15322
102
105
@@ -174,6 +177,11 @@ def timeout(self, value: float | str) -> None:
174
177
"""
175
178
self ._context .timeout = float (value )
176
179
180
+ @property
181
+ def mode (self ) -> int :
182
+ """:return: the file permissions for the lockfile"""
183
+ return self ._context .mode
184
+
177
185
@abstractmethod
178
186
def _acquire (self ) -> None :
179
187
"""If the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file."""
0 commit comments