pgjones / hypercorn

Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test_startup_failure fails with trio 0.25.0

mweinelt opened this issue · comments

After upgrading trio to 0.25.0 we are seeing the following test failure:

hypercorn> _____________________________ test_startup_failure _____________________________
hypercorn>   + Exception Group Traceback (most recent call last):
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/runner.py", line 340, in from_call
hypercorn>   |     result: Optional[TResult] = func()
hypercorn>   |                                 ^^^^^^
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/runner.py", line 240, in <lambda>
hypercorn>   |     lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
hypercorn>   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__
hypercorn>   |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec
hypercorn>   |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 181, in _multicall
hypercorn>   |     return outcome.get_result()
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_result.py", line 99, in get_result
hypercorn>   |     raise exc.with_traceback(exc.__traceback__)
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 166, in _multicall
hypercorn>   |     teardown.throw(outcome._exception)
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/threadexception.py", line 87, in pytest_runtest_call
hypercorn>   |     yield from thread_exception_runtest_hook()
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/threadexception.py", line 63, in thread_exception_runtest_hook
hypercorn>   |     yield
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 166, in _multicall
hypercorn>   |     teardown.throw(outcome._exception)
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 90, in pytest_runtest_call
hypercorn>   |     yield from unraisable_exception_runtest_hook()
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 65, in unraisable_exception_runtest_hook
hypercorn>   |     yield
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 166, in _multicall
hypercorn>   |     teardown.throw(outcome._exception)
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/logging.py", line 849, in pytest_runtest_call
hypercorn>   |     yield from self._runtest_for(item, "call")
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/logging.py", line 832, in _runtest_for
hypercorn>   |     yield
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 166, in _multicall
hypercorn>   |     teardown.throw(outcome._exception)
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/capture.py", line 883, in pytest_runtest_call
hypercorn>   |     return (yield)
hypercorn>   |             ^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 166, in _multicall
hypercorn>   |     teardown.throw(outcome._exception)
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/skipping.py", line 256, in pytest_runtest_call
hypercorn>   |     return (yield)
hypercorn>   |             ^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall
hypercorn>   |     res = hook_impl.function(*args)
hypercorn>   |           ^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/runner.py", line 182, in pytest_runtest_call
hypercorn>   |     raise e
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/runner.py", line 172, in pytest_runtest_call
hypercorn>   |     item.runtest()
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/python.py", line 1772, in runtest
hypercorn>   |     self.ihook.pytest_pyfunc_call(pyfuncitem=self)
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__
hypercorn>   |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec
hypercorn>   |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 181, in _multicall
hypercorn>   |     return outcome.get_result()
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_result.py", line 99, in get_result
hypercorn>   |     raise exc.with_traceback(exc.__traceback__)
hypercorn>   |   File "/nix/store/28vfwnihxhgy50f9z39nlzhi47az5cz4-python3.12-pluggy-1.4.0/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall
hypercorn>   |     res = hook_impl.function(*args)
hypercorn>   |           ^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/v151j4g2cz8pkgd78bizjw58jwjavky0-python3.12-pytest-8.1.1/lib/python3.12/site-packages/_pytest/python.py", line 195, in pytest_pyfunc_call
hypercorn>   |     result = testfunction(**testargs)
hypercorn>   |              ^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/dvv2iy025xm9x7422pwwc3rd0d2w23hq-python3.12-pytest-trio-0.8.0/lib/python3.12/site-packages/pytest_trio/plugin.py", line 348, in wrapper
hypercorn>   |     return run(partial(fn, **kwargs), clock=clock, instruments=instruments)
hypercorn>   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hypercorn>   |   File "/nix/store/jxlwjjdg45x361ixay8vzgclgi9dd249-python3.12-trio-0.25.0/lib/python3.12/site-packages/trio/_core/_run.py", line 2288, in run
hypercorn>   |     raise runner.main_task_outcome.error
hypercorn>   |   File "/nix/store/dvv2iy025xm9x7422pwwc3rd0d2w23hq-python3.12-pytest-trio-0.8.0/lib/python3.12/site-packages/pytest_trio/plugin.py", line 426, in _bootstrap_fixtures_and_run_test
hypercorn>   |     raise test_ctx.error_list[0]
hypercorn>   |   File "/nix/store/dvv2iy025xm9x7422pwwc3rd0d2w23hq-python3.12-pytest-trio-0.8.0/lib/python3.12/site-packages/pytest_trio/plugin.py", line 193, in _fixture_manager
hypercorn>   |     async with trio.open_nursery() as nursery_fixture:
hypercorn>   |   File "/nix/store/jxlwjjdg45x361ixay8vzgclgi9dd249-python3.12-trio-0.25.0/lib/python3.12/site-packages/trio/_core/_run.py", line 954, in __aexit__
hypercorn>   |     raise combined_error_from_nursery
hypercorn>   | ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
hypercorn>   +-+---------------- 1 ----------------
hypercorn>     | Exception Group Traceback (most recent call last):
hypercorn>     |   File "/nix/store/dvv2iy025xm9x7422pwwc3rd0d2w23hq-python3.12-pytest-trio-0.8.0/lib/python3.12/site-packages/pytest_trio/plugin.py", line 195, in _fixture_manager
hypercorn>     |     yield nursery_fixture
hypercorn>     |   File "/nix/store/dvv2iy025xm9x7422pwwc3rd0d2w23hq-python3.12-pytest-trio-0.8.0/lib/python3.12/site-packages/pytest_trio/plugin.py", line 250, in run
hypercorn>     |     await self._func(**resolved_kwargs)
hypercorn>     |   File "/build/source/tests/trio/test_lifespan.py", line 28, in test_startup_failure
hypercorn>     |     async with trio.open_nursery() as lifespan_nursery:
hypercorn>     |   File "/nix/store/jxlwjjdg45x361ixay8vzgclgi9dd249-python3.12-trio-0.25.0/lib/python3.12/site-packages/trio/_core/_run.py", line 954, in __aexit__
hypercorn>     |     raise combined_error_from_nursery
hypercorn>     | ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
hypercorn>     +-+---------------- 1 ----------------
hypercorn>       | Traceback (most recent call last):
hypercorn>       |   File "/nix/store/h8i8qr6jx7cy2pmsw784fq5zd4s8z9rk-python3.12-hypercorn-0.16.0/lib/python3.12/site-packages/hypercorn/trio/lifespan.py", line 34, in handle_lifespan
hypercorn>       |     await self.app(
hypercorn>       |   File "/nix/store/h8i8qr6jx7cy2pmsw784fq5zd4s8z9rk-python3.12-hypercorn-0.16.0/lib/python3.12/site-packages/hypercorn/app_wrappers.py", line 34, in __call__
hypercorn>       |     await self.app(scope, receive, send)
hypercorn>       |   File "/build/source/tests/helpers.py", line 80, in lifespan_failure
hypercorn>       |     await send({"type": "lifespan.startup.failed", "message": "Failure"})
hypercorn>       |   File "/nix/store/h8i8qr6jx7cy2pmsw784fq5zd4s8z9rk-python3.12-hypercorn-0.16.0/lib/python3.12/site-packages/hypercorn/trio/lifespan.py", line 93, in asgi_send
hypercorn>       |     raise LifespanFailureError("startup", message.get("message", ""))
hypercorn>       | hypercorn.utils.LifespanFailureError: Lifespan failure in startup. 'Failure'
hypercorn>       +------------------------------------

The current main tests succeed with trio 0.25.1 - so I'm not sure what this was. Please reopen if it is still an issue.

I just bisected this (with tox -e py312 between 0.16.0 and main) and found that c37a9ab is the first commit for which tests pass.

Then I tried cherry-picking that commit back to 0.16.0 (which was a bit harder than necessary since it mixed functional changes with reformatting), but it wasn’t a fix by itself.

Are you by chance planning a release any time soon?

Ah, I bisected on test_startup_failure specifically, and found 9400eb9, which does seem to be the fix for this particular issue. Cherry-picking both commits to 0.16.0 does seem to produce a patch that gets the tests working on the released hypercorn. Based on the contents of the two commits, this was purely a testing bug rather than a bug in hypercorn itself.