Skip to content

Commit 9501879

Browse files
committed
add test
1 parent 2518c76 commit 9501879

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Lib/test/test_asyncio/test_staggered.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,30 @@ async def do_set():
122122
self.assertIsNone(excs[0], None)
123123
self.assertIsInstance(excs[1], asyncio.CancelledError)
124124
self.assertIsInstance(excs[2], asyncio.CancelledError)
125+
126+
127+
async def test_cancelled(self):
128+
log = []
129+
with self.assertRaises(TimeoutError):
130+
async with asyncio.timeout(None) as cs_outer, asyncio.timeout(None) as cs_inner:
131+
async def coro_fn():
132+
cs_inner.reschedule(-1)
133+
await asyncio.sleep(0)
134+
try:
135+
await asyncio.sleep(0)
136+
except asyncio.CancelledError:
137+
log.append("cancelled 1")
138+
139+
cs_outer.reschedule(-1)
140+
await asyncio.sleep(0)
141+
try:
142+
await asyncio.sleep(0)
143+
except asyncio.CancelledError:
144+
log.append("cancelled 2")
145+
try:
146+
await staggered_race([coro_fn], delay=None)
147+
except asyncio.CancelledError:
148+
log.append("cancelled 3")
149+
raise
150+
151+
self.assertListEqual(log, ["cancelled 1", "cancelled 2", "cancelled 3"])

0 commit comments

Comments
 (0)