pulp / pulpcore

Pulp 3 pulpcore package https://pypi.org/project/pulpcore/
GNU General Public License v2.0
276 stars 111 forks source link

async-timeout no longer pulled in by aiohttp when using Python 3.11 #4923

Closed quba42 closed 7 months ago

quba42 commented 7 months ago

Version I suspect it is all versions using the following PR (https://github.com/pulp/pulpcore/pull/4902) and running Python 3.11.

Describe the bug We found it running an oci-env command in an oci-env using Python 3.11:

$ oci-env poll --wait 15 --attempts 30
++ oci-env poll --wait 15 --attempts 30
2024-01-11 16:34:07,397 - INFO - utils.py:36 - USING /home/gitlab-runner/builds/wwZGoy39D/0/orcharhino/pulp_components/pulpcore/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2024-01-11 16:34:07,402 - INFO - utils.py:36 - USING /home/gitlab-runner/builds/wwZGoy39D/0/orcharhino/pulp_components/pulpcore/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2024-01-11 16:34:07,411 - INFO - utils.py:36 - USING /home/gitlab-runner/builds/wwZGoy39D/0/orcharhino/pulp_components/pulpcore/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2024-01-11 16:44:59,932 - ERROR - utils.py:41 - Failed to start [oci_env_pulp_1] http://localhost:5001Traceback (most recent call last):
  File "/usr/local/bin/dynaconf", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/core.py", line 217, in __call__
    def __call__(A,*B,**C):return A.main(*B,**C)
                                  ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/core.py", line 201, in main
    H=E.invoke(F)
      ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/core.py", line 340, in invoke
    E,G,D=B.resolve_command(A,D);A.invoked_subcommand=E;Command.invoke(B,A);C=G.make_context(E,D,parent=A)
                                                        ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/core.py", line 284, in invoke
    if A.callback is not _A:return ctx.invoke(A.callback,**ctx.params)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/core.py", line 166, in invoke
    with G:return A(*B,**E)
                  ^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/vendor/click/decorators.py", line 21, in A
    def A(*A,**B):return f(get_current_context(),*A,**B)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dynaconf/cli.py", line 226, in main
    set_settings(ctx, instance)
  File "/usr/local/lib/python3.11/site-packages/dynaconf/cli.py", line 85, in set_settings
    django.setup()
  File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/src/pulpcore/pulpcore/app/apps.py", line 250, in ready
    super().ready()
  File "/src/pulpcore/pulpcore/app/apps.py", line 126, in ready
    self.import_viewsets()
  File "/src/pulpcore/pulpcore/app/apps.py", line 163, in import_viewsets
    from pulpcore.app.viewsets import NamedModelViewSet
  File "/src/pulpcore/pulpcore/app/viewsets/__init__.py", line 1, in <module>
    from .base import (
  File "/src/pulpcore/pulpcore/app/viewsets/base.py", line 19, in <module>
    from pulpcore.app import tasks
  File "/src/pulpcore/pulpcore/app/tasks/__init__.py", line 25, in <module>
    from .analytics import post_analytics
  File "/src/pulpcore/pulpcore/app/tasks/analytics.py", line 6, in <module>
    import async_timeout
ModuleNotFoundError: No module named 'async_timeout'api/v3/status/ after 450 seconds

Additional context My understanding is that async-timeout is needed by pulpcore here:

$ git grep async_timeout
pulpcore/app/tasks/analytics.py:import async_timeout
pulpcore/app/tasks/analytics.py:            async with async_timeout.timeout(300):

Until now this dependency was only satisfied because aiohttp pulled it in. With a new enough version of aiohttp running under Python 3.11 this is no longer the case. We probably need to add the dependency explicitly to pulpcore. (In the relevant version combination.)

mdellweg commented 7 months ago

I would even add the requirement only for python<3.11 and adopt using the upstreamed version of timeout with 3.11.