mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +00:00
GH-110796: fix intermittent test failure in test_current_exceptions
This commit is contained in:
parent
6478dea3c8
commit
2f59d418cf
1 changed files with 3 additions and 6 deletions
|
|
@ -511,7 +511,7 @@ class SysModuleTest(unittest.TestCase):
|
||||||
# Spawn a thread that blocks at a known place. Then the main
|
# Spawn a thread that blocks at a known place. Then the main
|
||||||
# thread does sys._current_frames(), and verifies that the frames
|
# thread does sys._current_frames(), and verifies that the frames
|
||||||
# returned make sense.
|
# returned make sense.
|
||||||
entered_g = threading.Event()
|
g_raised = threading.Event()
|
||||||
leave_g = threading.Event()
|
leave_g = threading.Event()
|
||||||
thread_info = [] # the thread's id
|
thread_info = [] # the thread's id
|
||||||
|
|
||||||
|
|
@ -520,22 +520,19 @@ class SysModuleTest(unittest.TestCase):
|
||||||
|
|
||||||
def g456():
|
def g456():
|
||||||
thread_info.append(threading.get_ident())
|
thread_info.append(threading.get_ident())
|
||||||
entered_g.set()
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
raise ValueError("oops")
|
raise ValueError("oops")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
g_raised.set()
|
||||||
if leave_g.wait(timeout=support.LONG_TIMEOUT):
|
if leave_g.wait(timeout=support.LONG_TIMEOUT):
|
||||||
break
|
break
|
||||||
|
|
||||||
t = threading.Thread(target=f123)
|
t = threading.Thread(target=f123)
|
||||||
t.start()
|
t.start()
|
||||||
entered_g.wait()
|
g_raised.wait(timeout=support.LONG_TIMEOUT)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# At this point, t has finished its entered_g.set(), although it's
|
|
||||||
# impossible to guess whether it's still on that line or has moved on
|
|
||||||
# to its leave_g.wait().
|
|
||||||
self.assertEqual(len(thread_info), 1)
|
self.assertEqual(len(thread_info), 1)
|
||||||
thread_id = thread_info[0]
|
thread_id = thread_info[0]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue