8000 bpo-33723: Fix test_time.test_thread_time() (GH-10724) · python/cpython@5350dd1 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 5350dd1

Browse files
bpo-33723: Fix test_time.test_thread_time() (GH-10724)
Tolerate up to 30 ms, instead of 15 min, in other threads. (cherry picked from commit 65c216e) Co-authored-by: Victor Stinner <vstinner@redhat.com>
1 parent 6f8cab0 commit 5350dd1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/test_time.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ def test_process_time(self):
497497
self.assertLess(stop - start, 0.020)
498498

499499
# bpo-33723: A busy loop of 100 ms should increase process_time()
500-
# by at least 15 ms
500+
# by at least 15 ms. Tolerate 15 ms because of the bad resolution of
501+
# the clock on Windows (around 15.6 ms).
501502
min_time = 0.015
502503
busy_time = 0.100
503504

@@ -535,8 +536,11 @@ def test_thread_time(self):
535536
self.assertLess(stop - start, 0.020)
536537

537538
# bpo-33723: A busy loop of 100 ms should increase thread_time()
538-
# by at least 15 ms
539+
# by at least 15 ms, but less than 30 ms in other threads.
540+
# Tolerate 15 and 30 ms because of the bad resolution
541+
# of the clock on Windows (around 15.6 ms).
539542
min_time = 0.015
543+
max_time = 0.030
540544
busy_time = 0.100
541545

542546
# thread_time() should include CPU time spent in current thread...
@@ -551,7 +555,7 @@ def test_thread_time(self):
551555
t.start()
552556
t.join()
553557
stop = time.thread_time()
554-
self.assertLess(stop - start, min_time)
558+
self.assertLess(stop - start, max_time)
555559

556560
info = time.get_clock_info('thread_time')
557561
self.assertTrue(info.monotonic)

0 commit comments

Comments
 (0)
0