Skip to content

Async streaming unit tests fail with Python3.13 due to coroutine method 'aclose' of X was never awaited #698

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

Closed
parthea opened this issue Sep 13, 2024 · 2 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@parthea
Copy link
Collaborator

parthea commented Sep 13, 2024

See build log here where some unit tests fail in python 3.13 due to a runtime warning.

=============================================================================================================================== ERRORS ================================================================================================================================
___________________________________________________________________________________________ ERROR at teardown of TestAsyncStreamingRetry.test___call___generator_send_retry ___________________________________________________________________________________________
[gw23] linux -- Python 3.13.0 /usr/local/google/home/partheniou/git/python-api-core/.nox/unit_wo_grpc-3-13/bin/python

cls = <class '_pytest.runner.CallInfo'>, func = <function call_and_report.<locals>.<lambda> at 0x7f511d200860>, when = 'teardown', reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: Callable[[], TResult],
        when: Literal["collect", "setup", "call", "teardown"],
        reraise: type[BaseException] | tuple[type[BaseException], ...] | None = None,
    ) -> CallInfo[TResult]:
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :type func: Callable[[], _pytest.runner.TResult]
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: TResult | None = func()

.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/runner.py:341: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/runner.py:242: in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/pluggy/_hooks.py:513: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/pluggy/_manager.py:120: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/threadexception.py:97: in pytest_runtest_teardown
    yield from thread_exception_runtest_hook()
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/threadexception.py:68: in thread_exception_runtest_hook
    yield
.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/unraisableexception.py:100: in pytest_runtest_teardown
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def unraisable_exception_runtest_hook() -> Generator[None]:
        with catch_unraisable_exception() as cm:
            try:
                yield
            finally:
                if cm.unraisable:
                    if cm.unraisable.err_msg is not None:
                        err_msg = cm.unraisable.err_msg
                    else:
                        err_msg = "Exception ignored in"
                    msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                    msg += "".join(
                        traceback.format_exception(
                            cm.unraisable.exc_type,
                            cm.unraisable.exc_value,
                            cm.unraisable.exc_traceback,
                        )
                    )
>                   warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E                   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object retry_target_stream at 0x7f511c582f20>
E                   
E                   Traceback (most recent call last):
E                     File "/usr/local/google/home/partheniou/.pyenv/versions/3.13.0a3/lib/python3.13/asyncio/base_events.py", line 734, in close
E                       self._ready.clear()
E                       ~~~~~~~~~~~~~~~~~^^
E                   RuntimeWarning: coroutine method 'aclose' of 'retry_target_stream' was never awaited

.nox/unit_wo_grpc-3-13/lib/python3.13/site-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning
------------------------------------------------------------------------------------------------------------------------ Captured log teardown ------------------------------------------------------------------------------------------------------------------------
ERROR    asyncio:base_events.py:1834 Task was destroyed but it is pending!
task: <Task pending name='Task-2' coro=<<async_generator_athrow without __name__>()>>
________________________________________________________________________________________________ ERROR at teardown of TestAsyncIterator.test__page_aiter_no_increment
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 13, 2024
@daniel-sanche
Copy link
Contributor

This was reported as an issue and fixed in cpython: python/cpython#117536

I think we might only be seeing this because we're running tests against 3.13.0-rc.2

@parthea
Copy link
Collaborator Author

parthea commented Oct 22, 2024

Closing as obsolete

@parthea parthea closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants