Skip to content

Commit

Permalink
use time.perf_counter instead of time.monotonic (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
zpz committed Mar 14, 2023
1 parent 8816db7 commit df6b13c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
=========
v3.9.1 (2023-03-14)
-------------------
- Use ``time.perf_counter`` instead of ``time.monotonic`` for calculating timeouts.

v3.9.0 (2022-12-28)
-------------------
- Move build backend to ``hatchling`` :pr:`185 - by :user:`gaborbernat`.
Expand Down
4 changes: 2 additions & 2 deletions src/filelock/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def acquire(

lock_id = id(self)
lock_filename = self._lock_file
start_time = time.monotonic()
start_time = time.perf_counter()
try:
while True:
with self._thread_lock:
Expand All @@ -178,7 +178,7 @@ def acquire(
elif blocking is False:
_LOGGER.debug("Failed to immediately acquire lock %s on %s", lock_id, lock_filename)
raise Timeout(self._lock_file)
elif 0 <= timeout < time.monotonic() - start_time:
elif 0 <= timeout < time.perf_counter() - start_time:
_LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename)
raise Timeout(self._lock_file)
else:
Expand Down
1 change: 1 addition & 0 deletions whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ msvcrt
nblck
nitpicky
notset
perf
pygments
rdwr
ro
Expand Down

0 comments on commit df6b13c

Please sign in to comment.