From 543a54116f0ef5c8a545386a5820971698951de0 Mon Sep 17 00:00:00 2001 From: zpz Date: Sun, 5 Feb 2023 23:59:34 -0800 Subject: [PATCH 1/5] use time.perf_counter instead of time.monotonic --- docs/changelog.rst | 4 ++++ src/filelock/_api.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 184ac919..be3452a7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,5 +1,9 @@ Changelog ========= +in progress +----------- +- 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`. diff --git a/src/filelock/_api.py b/src/filelock/_api.py index 1f046625..5ca63130 100644 --- a/src/filelock/_api.py +++ b/src/filelock/_api.py @@ -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: @@ -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: From 8a12a4fef14120184c3cc0d8fe524c4ac132f6de Mon Sep 17 00:00:00 2001 From: zpz Date: Thu, 9 Feb 2023 21:54:47 -0800 Subject: [PATCH 2/5] ignore flake8 error on perf spelling --- src/filelock/_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filelock/_api.py b/src/filelock/_api.py index 5ca63130..c6811ae5 100644 --- a/src/filelock/_api.py +++ b/src/filelock/_api.py @@ -164,7 +164,7 @@ def acquire( lock_id = id(self) lock_filename = self._lock_file - start_time = time.perf_counter() + start_time = time.perf_counter() # noqa: SC200 try: while True: with self._thread_lock: @@ -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.perf_counter() - start_time: + elif 0 <= timeout < time.perf_counter() - start_time: # noqa: SC200 _LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename) raise Timeout(self._lock_file) else: From 00f92a6f63fbd6cc3efbfee453f96d08cc1dfb5d Mon Sep 17 00:00:00 2001 From: zpz Date: Tue, 14 Mar 2023 00:15:25 -0700 Subject: [PATCH 3/5] minor --- docs/changelog.rst | 2 +- whitelist.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index be3452a7..fbb29718 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,6 @@ Changelog ========= -in progress +v3.9.1 (2023-03-14) ----------- - Use ``time.perf_counter`` instead of ``time.monotonic`` for calculating timeouts. diff --git a/whitelist.txt b/whitelist.txt index e127de8e..bd1b90bb 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -20,6 +20,7 @@ msvcrt nblck nitpicky notset +perf pygments rdwr ro From fbb6fe673911e5c41219c7c34c4247c4540ffe16 Mon Sep 17 00:00:00 2001 From: zpz Date: Tue, 14 Mar 2023 00:19:47 -0700 Subject: [PATCH 4/5] formatting --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fbb29718..2e220975 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,7 +1,7 @@ Changelog ========= v3.9.1 (2023-03-14) ------------ +------------------- - Use ``time.perf_counter`` instead of ``time.monotonic`` for calculating timeouts. v3.9.0 (2022-12-28) From 79edaef964f4089499948c32c93d27d804d5ff34 Mon Sep 17 00:00:00 2001 From: zpz Date: Tue, 14 Mar 2023 00:21:13 -0700 Subject: [PATCH 5/5] minor --- src/filelock/_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filelock/_api.py b/src/filelock/_api.py index c6811ae5..5ca63130 100644 --- a/src/filelock/_api.py +++ b/src/filelock/_api.py @@ -164,7 +164,7 @@ def acquire( lock_id = id(self) lock_filename = self._lock_file - start_time = time.perf_counter() # noqa: SC200 + start_time = time.perf_counter() try: while True: with self._thread_lock: @@ -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.perf_counter() - start_time: # noqa: SC200 + 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: