Skip to content

Commit 8d5f3cd

Browse files
authored
gh-133419: fix test_external_inspection race assert (#133433)
Follow-up of commit c4cc5d5, fix more tests.
1 parent b97328e commit 8d5f3cd

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

Lib/test/test_external_inspection.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def baz():
5959
foo()
6060
6161
def foo():
62-
sock.sendall(b"ready"); time.sleep(1000) # same line number
62+
sock.sendall(b"ready"); time.sleep(10_000) # same line number
6363
6464
bar()
6565
"""
@@ -121,8 +121,7 @@ def test_async_remote_stack_trace(self):
121121
sock.connect(('localhost', {port}))
122122
123123
def c5():
124-
sock.sendall(b"ready")
125-
time.sleep(10000)
124+
sock.sendall(b"ready"); time.sleep(10_000) # same line number
126125
127126
async def c4():
128127
await asyncio.sleep(0)
@@ -194,10 +193,10 @@ def new_eager_loop():
194193
root_task = "Task-1"
195194
expected_stack_trace = [
196195
[
197-
("c5", script_name, 11),
198-
("c4", script_name, 15),
199-
("c3", script_name, 18),
200-
("c2", script_name, 21),
196+
("c5", script_name, 10),
197+
("c4", script_name, 14),
198+
("c3", script_name, 17),
199+
("c2", script_name, 20),
201200
],
202201
"c2_root",
203202
[
@@ -213,13 +212,13 @@ def new_eager_loop():
213212
taskgroups.__file__,
214213
ANY,
215214
),
216-
("main", script_name, 27),
215+
("main", script_name, 26),
217216
],
218217
"Task-1",
219218
[],
220219
],
221220
[
222-
[("c1", script_name, 24)],
221+
[("c1", script_name, 23)],
223222
"sub_main_1",
224223
[
225224
[
@@ -234,15 +233,15 @@ def new_eager_loop():
234233
taskgroups.__file__,
235234
ANY,
236235
),
237-
("main", script_name, 27),
236+
("main", script_name, 26),
238237
],
239238
"Task-1",
240239
[],
241240
]
242241
],
243242
],
244243
[
245-
[("c1", script_name, 24)],
244+
[("c1", script_name, 23)],
246245
"sub_main_2",
247246
[
248247
[
@@ -257,7 +256,7 @@ def new_eager_loop():
257256
taskgroups.__file__,
258257
ANY,
259258
),
260-
("main", script_name, 27),
259+
("main", script_name, 26),
261260
],
262261
"Task-1",
263262
[],
@@ -287,8 +286,7 @@ def test_asyncgen_remote_stack_trace(self):
287286
sock.connect(('localhost', {port}))
288287
289288
async def gen_nested_call():
290-
sock.sendall(b"ready")
291-
time.sleep(10000)
289+
sock.sendall(b"ready"); time.sleep(10_000) # same line number
292290
293291
async def gen():
294292
for num in range(2):
@@ -336,9 +334,9 @@ async def main():
336334

337335
expected_stack_trace = [
338336
[
339-
("gen_nested_call", script_name, 11),
340-
("gen", script_name, 17),
341-
("main", script_name, 20),
337+
("gen_nested_call", script_name, 10),
338+
("gen", script_name, 16),
339+
("main", script_name, 19),
342340
],
343341
"Task-1",
344342
[],
@@ -365,8 +363,7 @@ def test_async_gather_remote_stack_trace(self):
365363
366364
async def deep():
367365
await asyncio.sleep(0)
368-
sock.sendall(b"ready")
369-
time.sleep(10000)
366+
sock.sendall(b"ready"); time.sleep(10_000) # same line number
370367
371368
async def c1():
372369
await asyncio.sleep(0)
@@ -413,9 +410,9 @@ async def main():
413410
stack_trace[2].sort(key=lambda x: x[1])
414411

415412
expected_stack_trace = [
416-
[("deep", script_name, ANY), ("c1", script_name, 16)],
413+
[("deep", script_name, 11), ("c1", script_name, 15)],
417414
"Task-2",
418-
[[[("main", script_name, 22)], "Task-1", []]],
415+
[[[("main", script_name, 21)], "Task-1", []]],
419416
]
420417
self.assertEqual(stack_trace, expected_stack_trace)
421418

@@ -439,15 +436,14 @@ def test_async_staggered_race_remote_stack_trace(self):
439436
440437
async def deep():
441438
await asyncio.sleep(0)
442-
sock.sendall(b"ready")
443-
time.sleep(10000)
439+
sock.sendall(b"ready"); time.sleep(10_000) # same line number
444440
445441
async def c1():
446442
await asyncio.sleep(0)
447443
await deep()
448444
449445
async def c2():
450-
await asyncio.sleep(10000)
446+
await asyncio.sleep(10_000)
451447
452448
async def main():
453449
await asyncio.staggered.staggered_race(
@@ -490,16 +486,16 @@ async def main():
490486
stack_trace[2].sort(key=lambda x: x[1])
491487
expected_stack_trace = [
492488
[
493-
("deep", script_name, ANY),
494-
("c1", script_name, 16),
489+
("deep", script_name, 11),
490+
("c1", script_name, 15),
495491
("staggered_race.<locals>.run_one_coro", staggered.__file__, ANY),
496492
],
497493
"Task-2",
498494
[
499495
[
500496
[
501497
("staggered_race", staggered.__file__, ANY),
502-
("main", script_name, 22),
498+
("main", script_name, 21),
503499
],
504500
"Task-1",
505501
[],

0 commit comments

Comments
 (0)