Skip to content

Commit

Permalink
Fix a test that was leaving unattended tasks after the test
Browse files Browse the repository at this point in the history
The request was cancelled fast enough, and the response writer was closed. But the response handler continued running and writing into that closed transport — long enough to be noticed by the cleanup fixture.

Signed-off-by: Sergey Vasilyev <[email protected]>
  • Loading branch information
nolar committed Oct 2, 2022
1 parent b7f8f0b commit efd0618
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/apis/test_api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async def serve_slowly():
async def test_stopper_in_streams(
resp_mocker, aresponses, hostname, method, delay, expected, settings, logger):

async def stream_slowly(request: aiohttp.ClientRequest):
async def stream_slowly(request: aiohttp.web.Request) -> aiohttp.web.StreamResponse:
response = aiohttp.web.StreamResponse()
await response.prepare(request)
await asyncio.sleep(0.05)
Expand All @@ -256,3 +256,5 @@ async def stream_slowly(request: aiohttp.ClientRequest):
items.append(item)

assert items == expected

await asyncio.sleep(0.1) # give the response some time to be cancelled and its tasks closed

0 comments on commit efd0618

Please sign in to comment.