11import logging
22import os
33import time
4+ import warnings
45from abc import ABC , abstractmethod
56from threading import Lock
67from types import TracebackType
@@ -106,13 +107,19 @@ def is_locked(self) -> bool:
106107 """
107108 return self ._lock_file_fd is not None
108109
109- def acquire (self , timeout : Optional [float ] = None , poll_intervall : float = 0.05 ) -> AcquireReturnProxy :
110+ def acquire (
111+ self ,
112+ timeout : Optional [float ] = None ,
113+ poll_interval : float = 0.05 ,
114+ poll_intervall : Optional [float ] = None ,
115+ ) -> AcquireReturnProxy :
110116 """
111117 Try to acquire the file lock.
112118
113119 :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
114120 if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
115- :param poll_intervall: interval of trying to acquire the lock file
121+ :param poll_interval: interval of trying to acquire the lock file
122+ :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
116123 :raises Timeout: if fails to acquire lock within the timeout period
117124 :return: a context object that will unlock the file when the context is exited
118125
@@ -131,15 +138,19 @@ def acquire(self, timeout: Optional[float] = None, poll_intervall: float = 0.05)
131138
132139 .. versionchanged:: 2.0.0
133140
134- This method returns now a *proxy* object instead of *self*,
135- so that it can be used in a with statement without side effects.
136-
141+ This method returns now a *proxy* object instead of *self*, so that it can be used in a with statement \
142+ without side effects.
137143
138144 """
139145 # Use the default timeout, if no timeout is provided.
140146 if timeout is None :
141147 timeout = self .timeout
142148
149+ if poll_intervall is not None :
150+ msg = "use poll_interval instead of poll_intervall"
151+ warnings .warn (msg , DeprecationWarning )
152+ poll_interval = poll_intervall
153+
143154 # Increment the number right at the beginning. We can still undo it, if something fails.
144155 with self ._thread_lock :
145156 self ._lock_counter += 1
@@ -162,8 +173,8 @@ def acquire(self, timeout: Optional[float] = None, poll_intervall: float = 0.05)
162173 raise Timeout (self ._lock_file )
163174 else :
164175 msg = "Lock %s not acquired on %s, waiting %s seconds ..."
165- _LOGGER .debug (msg , lock_id , lock_filename , poll_intervall )
166- time .sleep (poll_intervall )
176+ _LOGGER .debug (msg , lock_id , lock_filename , poll_interval )
177+ time .sleep (poll_interval )
167178 except BaseException : # Something did go wrong, so decrement the counter.
168179 with self ._thread_lock :
169180 self ._lock_counter = max (0 , self ._lock_counter - 1 )
0 commit comments