web-platform-tests / wpt

Test suites for Web platform specs — including WHATWG, W3C, and others
https://web-platform-tests.org/
Other
4.92k stars 3.07k forks source link

`tools/` integration test fails due to `NotImplementedError` in `asyncio.StreamWriter.__del__` #41675

Closed jonathan-j-lee closed 2 days ago

jonathan-j-lee commented 1 year ago

The tools/ integration tests (Python 3.11) Taskcluster step fails with:

____________________________ test_run_failing_test _____________________________
cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7f77a66fafc0>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        """Call func, wrapping the result in a CallInfo.

        :param func:
            The function to call. Called without arguments.
        :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: Optional[TResult] = func()
.tox/py311/lib/python3.11/site-packages/_pytest/runner.py:341: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py311/lib/python3.11/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/py311/lib/python3.11/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/py311/lib/python3.11/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
.tox/py311/lib/python3.11/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            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: <function StreamWriter.__del__ at 0x7f77affc6d40>
E               
E               Traceback (most recent call last):
E                 File "/usr/lib/python3.11/asyncio/streams.py", line 395, in __del__
E                   if not self._transport.is_closing():
E                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E                 File "/usr/lib/python3.11/asyncio/transports.py", line 25, in is_closing
E                   raise NotImplementedError
E               NotImplementedError
.tox/py311/lib/python3.11/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning

The error seems to emanate from aioquic, which backs webtransport_h3_server. Skimming the aioquic source, it looks like aioquic attempts to create a streaming protocol with a asyncio.DatagramTransport. This makes sense for QUIC, but maybe asyncio.DatagramTransport doesn't work well with protocols other than asyncio.DatagramProtocol in practice.

For now, disable the WebTransport over H3 server for integration tests that don't need them (#41673).

CC @bashi

gsnedders commented 1 year ago

Can you file a bug on aioquic and add it to the ignored warnings in pytest.ini?

jlaine commented 6 months ago

This is solved in https://github.com/aiortc/aioquic/pull/477 and the fix will be available in the next release (expected this month).