Skip to content

Commit 0fc940a

Browse files
authored
test_bsddb3 tolerates smaller timeout on Windows (#2840)
bpo-30850: On Windows, test04_lock_timeout2() now tolerates 50 ms whereas 100 ms is expected. The lock sometimes times out after only 58 ms. Windows clocks have a bad resolution and bad accuracy.
1 parent 123a58b commit 0fc940a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Lib/bsddb/test/test_lock.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
TestCases for testing the locking sub-system.
33
"""
44

5+
import sys
56
import time
67

78
import unittest
@@ -10,7 +11,6 @@
1011

1112
if have_threads :
1213
from threading import Thread
13-
import sys
1414
if sys.version_info[0] < 3 :
1515
from threading import currentThread
1616
else :
@@ -129,7 +129,14 @@ def deadlock_detection() :
129129
end_time=time.time()
130130
deadlock_detection.end=True
131131
# Floating point rounding
132-
self.assertGreaterEqual(end_time-start_time, 0.0999)
132+
if sys.platform == 'win32':
133+
# bpo-30850: On Windows, tolerate 50 ms whereas 100 ms is expected.
134+
# The lock sometimes times out after only 58 ms. Windows clocks
135+
# have a bad resolution and bad accuracy.
136+
min_dt = 0.050
137+
else:
138+
min_dt = 0.0999
139+
self.assertGreaterEqual(end_time-start_time, min_dt)
133140
self.env.lock_put(lock)
134141
t.join()
135142

0 commit comments

Comments
 (0)