Skip to content

Small improvements to payload cleanup fixture #10943

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
merged 2 commits into from
May 22, 2025
Merged
Changes from 1 commit
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
Next Next commit
Small improvements to payload cleanup fixture
  • Loading branch information
bdraco committed May 22, 2025
commit 44a5969d752ad3b3144365c5ba7e5ff3733fef3d
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, Callable, Generator, Iterator
from typing import Any, AsyncIterator, Callable, Generator, Iterator
from unittest import mock
from uuid import uuid4

Expand Down Expand Up @@ -338,15 +338,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