Skip to content

Commit df6b13c

Browse files
authored
use time.perf_counter instead of time.monotonic (#194)
1 parent 8816db7 commit df6b13c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/changelog.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Changelog
22
=========
3+
v3.9.1 (2023-03-14)
4+
-------------------
5+
- Use ``time.perf_counter`` instead of ``time.monotonic`` for calculating timeouts.
6+
37
v3.9.0 (2022-12-28)
48
-------------------
59
- Move build backend to ``hatchling`` :pr:`185 - by :user:`gaborbernat`.

src/filelock/_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def acquire(
164164

165165
lock_id = id(self)
166166
lock_filename = self._lock_file
167-
start_time = time.monotonic()
167+
start_time = time.perf_counter()
168168
try:
169169
while True:
170170
with self._thread_lock:
@@ -178,7 +178,7 @@ def acquire(
178178
elif blocking is False:
179179
_LOGGER.debug("Failed to immediately acquire lock %s on %s", lock_id, lock_filename)
180180
raise Timeout(self._lock_file)
181-
elif 0 <= timeout < time.monotonic() - start_time:
181+
elif 0 <= timeout < time.perf_counter() - start_time:
182182
_LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename)
183183
raise Timeout(self._lock_file)
184184
else:

whitelist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ msvcrt
2020
nblck
2121
nitpicky
2222
notset
23+
perf
2324
pygments
2425
rdwr
2526
ro

0 commit comments

Comments
 (0)