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

Skip to content

Commit d6345de

Browse files
authored
bpo-33723: Fix test_time.test_thread_time() (GH-8267)
The test failed on AMD64 Debian root 3.x buildbot because the busy loop of 100 ms only increased time.thread_time() by 19.9 ms which is smaller than 20 ms. Modify the test to tolerate a delta of at least 15 ms instead of 20 ms.
1 parent 9e9b2c3 commit d6345de

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_time.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,24 @@ def test_thread_time(self):
529529
# on Windows
530530
self.assertLess(stop - start, 0.020)
531531

532+
# bpo-33723: A busy loop of 100 ms should increase thread_time()
533+
# by at least 15 ms
534+
min_time = 0.015
535+
busy_time = 0.100
536+
532537
# thread_time() should include CPU time spent in current thread...
533538
start = time.thread_time()
534-
busy_wait(0.100)
539+
busy_wait(busy_time)
535540
stop = time.thread_time()
536-
self.assertGreaterEqual(stop - start, 0.020) # machine busy?
541+
self.assertGreaterEqual(stop - start, min_time)
537542

538543
# ...but not in other threads
539-
t = threading.Thread(target=busy_wait, args=(0.100,))
544+
t = threading.Thread(target=busy_wait, args=(busy_time,))
540545
start = time.thread_time()
541546
t.start()
542547
t.join()
543548
stop = time.thread_time()
544-
self.assertLess(stop - start, 0.020)
549+
self.assertLess(stop - start, min_time)
545550

546551
info = time.get_clock_info('thread_time')
547552
self.assertTrue(info.monotonic)

0 commit comments

Comments
 (0)
0