Skip to content

Tests with Python 3.11.0b1: RuntimeError: no running event loop / There is no current event loop in thread 'MainThread' #6757

Closed
@hroncok

Description

Describe the bug

Hello, in Fedora, we build all Python packages with pre-releases of Python 3.11. With Python 3.11.0b1, we see test failures of aiohttp 3.8.1, I can reproduce them with the current master barnch.

To Reproduce

  1. git clone yarl (@ v1.7.2) , frozenlist (@ v1.3.0) and aiohttp (@ master)
  2. python3.11 -m venv venv and . venv/bin/activate
  3. In yarl and frozenlist, make cythonize with the recent cython version, then pip install .
  4. In aiohttp I had to do some changes to make it build
    1. I replaced cython==0.29.27 with cython==0.29.30 or just cython in requirements/*
    2. I replaced the git-submodule copy of llhttp with the system one (6.0.6) as I was unable to make the nodejs build thing work, sorry
    3. I removed the coverage pytest options, as coverage makes pytest fail immediately
  5. make cythonize
  6. pip install . pytest pytest-mock
  7. run pytest, I've used pytest tests/test_client_functional.py tests/test_client_request.py tests/test_loop.py tests/test_test_utils.py as that is enough to get the failures
diff --git a/aiohttp/_cparser.pxd b/aiohttp/_cparser.pxd
index 165dd61d..49055d6a 100644
--- a/aiohttp/_cparser.pxd
+++ b/aiohttp/_cparser.pxd
@@ -10,7 +10,7 @@ from libc.stdint cimport (
 )
 
 
-cdef extern from "../vendor/llhttp/build/llhttp.h":
+cdef extern from "llhttp.h":
 
     struct llhttp__internal_s:
         int32_t _index
diff --git a/requirements/constraints.txt b/requirements/constraints.txt
index e1f6351b..26eed534 100644
--- a/requirements/constraints.txt
+++ b/requirements/constraints.txt
@@ -60,7 +60,7 @@ cryptography==36.0.1 ; platform_machine != "i686"
     #   -r requirements/test.txt
     #   pyjwt
     #   trustme
-cython==0.29.27
+cython==0.29.30
     # via -r requirements/cython.txt
 distlib==0.3.3
     # via virtualenv
diff --git a/requirements/cython.txt b/requirements/cython.txt
index 5cacc7e0..0a5b24bc 100644
--- a/requirements/cython.txt
+++ b/requirements/cython.txt
@@ -1,3 +1,3 @@
 -r multidict.txt
 -r typing-extensions.txt  # required for parsing aiohttp/hdrs.py by tools/gen.py
-cython==0.29.27
+cython
diff --git a/setup.cfg b/setup.cfg
index e6dd14bc..e254f490 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -123,10 +123,6 @@ addopts =
     # show values of the local vars in errors:
     --showlocals
 
-    # `pytest-cov`:
-    --cov=aiohttp
-    --cov=tests/
-
     # run tests that are not marked with dev_mode
     -m "not dev_mode"
 filterwarnings =
diff --git a/setup.py b/setup.py
index b27a54d6..0d70b1a7 100644
--- a/setup.py
+++ b/setup.py
@@ -33,12 +33,8 @@ extensions = [
         [
             "aiohttp/_http_parser.c",
             "aiohttp/_find_header.c",
-            "vendor/llhttp/build/c/llhttp.c",
-            "vendor/llhttp/src/native/api.c",
-            "vendor/llhttp/src/native/http.c",
         ],
-        define_macros=[("LLHTTP_STRICT_MODE", 0)],
-        include_dirs=["vendor/llhttp/build"],
+        libraries=["llhttp"],
     ),
     Extension("aiohttp._helpers", ["aiohttp/_helpers.c"]),
     Extension("aiohttp._http_writer", ["aiohttp/_http_writer.c"]),

Expected behavior

Tests pass.

Logs/tracebacks

See the next comment, the log was too long to paste here.

Python Version

$ python --version
Python 3.11.0b1

aiohttp Version

$ python -m pip show aiohttp
Name: aiohttp
Version: 4.0.0a1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: 
Author-email: 
License: Apache 2
Location: /home/churchyard/rpmbuild/fedora-scm/python-aiohttp/aiohttp/__venv__/lib64/python3.11/site-packages
Requires: aiosignal, async-timeout, charset-normalizer, frozenlist, multidict, typing-extensions, yarl
Required-by:

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 5.2.0
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/churchyard/rpmbuild/fedora-scm/python-aiohttp/aiohttp/__venv__/lib64/python3.11/site-packages
Requires: 
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.7.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/churchyard/rpmbuild/fedora-scm/python-aiohttp/aiohttp/__venv__/lib64/python3.11/site-packages
Requires: idna, multidict
Required-by: aiohttp

OS

Fedora Linux 35 or 37

Related component

Client

Additional context

We plan to update Fedora 37 to Python 3.11 after the second beta. Fedora 37 is the development version of Fedora.
While testing things, we need to do that in dependency order. Unfortunately, this blocks us from testing many other packages, as this is quite a popular library.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions