Skip to content

[PR #10943/b1e9462 backport][3.12] Small improvements to payload cleanup fixture #10944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/10943.bugfix.rst
10 changes: 4 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hashlib import md5, sha1, sha256
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Generator, Iterator
from typing import Any, AsyncIterator, Generator, Iterator
from unittest import mock
from uuid import uuid4

Expand Down Expand Up @@ -336,15 +336,13 @@ def parametrize_zlib_backend(


@pytest.fixture()
def cleanup_payload_pending_file_closes(
async def cleanup_payload_pending_file_closes(
loop: asyncio.AbstractEventLoop,
) -> Generator[None, None, None]:
) -> AsyncIterator[None]:
"""Ensure all pending file close operations complete during test teardown."""
yield
if payload._CLOSE_FUTURES:
# Only wait for futures from the current loop
loop_futures = [f for f in payload._CLOSE_FUTURES if f.get_loop() is loop]
if loop_futures:
loop.run_until_complete(
asyncio.gather(*loop_futures, return_exceptions=True)
)
await asyncio.gather(*loop_futures, return_exceptions=True)
Loading