Skip to content

Commit e8cdc4e

Browse files
author
r.inyakin
committed
test: fix ping test on windows
The `ping` method measures the duration using the `time.perf_counter()` function. It has the same resolution as `time.time()` on Unix, but provides higher resolution on Windows. Closes #214
1 parent 5003558 commit e8cdc4e

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Changed
1212

1313
### Fixed
14+
- Measure `ping()` response time with `time.perf_counter()` instead of
15+
`time.time()`. On Windows with Python 3.12 and older the latter has a
16+
resolution of 15.6 ms, so `ping()` could return `0.0` (PR #350).
1417

1518
## [1.3.0] - 2026-08-17
1619

‎tarantool/connection.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,9 +1910,9 @@ def ping(self, notime=False):
19101910
"""
19111911

19121912
request = RequestPing(self)
1913-
start_time = time.time()
1913+
start_time = time.perf_counter()
19141914
self._send_request(request)
1915-
finish_time = time.time()
1915+
finish_time = time.perf_counter()
19161916

19171917
if notime:
19181918
return "Success"

‎test/suites/test_dml.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ def test_05_ping(self):
171171
# Simple ping test
172172
# * No exceptions are raised
173173
# * Ping time > 0
174-
if sys.platform.startswith("win"):
175-
self.skipTest("Windows clock precision causes test to fail sometimes, see #214")
176-
177174
self.assertTrue(self.con.ping() > 0)
178175
self.assertEqual(self.con.ping(notime=True), "Success")
179176

0 commit comments

Comments
 (0)