tfranzel / drf-spectacular

Sane and flexible OpenAPI 3 schema generation for Django REST framework.
https://drf-spectacular.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.41k stars 266 forks source link

Sporatic uncaught exception: AssertionError: Schema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.) #1123

Open bradydean opened 11 months ago

bradydean commented 11 months ago

Describe the bug I have a /openapi endpoint, and occasionally the API fails with this exception. This happens a few times a day, but most of the time the spec generates successfully.

Traceback (most recent call last):
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/asgiref/sync.py", line 534, in thread_handler
    raise exc_info[1]
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/asgiref/sync.py", line 534, in thread_handler
    raise exc_info[1]
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/asgiref/sync.py", line 479, in __call__
    ret: _R = await loop.run_in_executor(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/asgiref/current_thread_executor.py", line 40, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/asgiref/sync.py", line 538, in thread_handler
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/django/views/decorators/cache.py", line 40, in _cache_controlled
    response = viewfunc(request, *args, **kw)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/views.py", line 83, in get
    return self._get_schema_response(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/views.py", line 91, in _get_schema_response
    data=generator.get_schema(request=request, public=self.serve_public),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/generators.py", line 268, in get_schema
    paths=self.parse(request, public),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/generators.py", line 239, in parse
    operation = view.schema.get_operation(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/utils.py", line 422, in get_operation
    return super().get_operation(path, path_regex, path_prefix, method, registry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/openapi.py", line 78, in get_operation
    parameters = self._get_parameters()
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/openapi.py", line 248, in _get_parameters
    **dict_helper(self._get_format_parameters()),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/openapi.py", line 225, in _get_format_parameters
    formats = self.map_renderers('format')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/drf_spectacular/openapi.py", line 1153, in map_renderers
    for r in self.view.get_renderers()
             ^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.11/lib/python3.11/site-packages/rest_framework/schemas/inspectors.py", line 58, in view
    assert self._view is not None, (
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Schema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.)

To Reproduce Cannot be reproduced locally, I just have production logs of it happening.

Expected behavior API spec generates successfully every time

bradydean commented 11 months ago

I found an instance of this error now, same exception, but different traceback

Traceback (most recent call last):
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 534, in thread_handler
    raise exc_info[1]
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 534, in thread_handler
    raise exc_info[1]
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 479, in __call__
    ret: _R = await loop.run_in_executor(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/current_thread_executor.py", line 40, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 538, in thread_handler
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/decorators/cache.py", line 54, in _view_wrapper
    response = viewfunc(request, *args, **kw)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/views.py", line 84, in get
    return self._get_schema_response(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/views.py", line 92, in _get_schema_response
    data=generator.get_schema(request=request, public=self.serve_public),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/generators.py", line 281, in get_schema
    paths=self.parse(request, public),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/generators.py", line 252, in parse
    operation = view.schema.get_operation(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/utils.py", line 424, in get_operation
    return super().get_operation(path, path_regex, path_prefix, method, registry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 111, in get_operation
    operation['responses'] = self._get_response_bodies()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 1367, in _get_response_bodies
    return {'200': self._get_response_for_code(response_serializers, '200', direction=direction)}
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 1444, in _get_response_for_code
    self._is_list_view(serializer)
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 145, in _is_list_view
    if hasattr(self.view, 'action'):
               ^^^^^^^^^
  File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/schemas/inspectors.py", line 58, in view
    assert self._view is not None, (
AssertionError: Schema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.)
tfranzel commented 11 months ago

Hey @bradydean,

can you reproduce this issue or is probabilistic again? I am still confused how this can happen for you. This is a very basic assumption failure that should never be seen by a user.

bradydean commented 11 months ago

Unfortunately I cannot reproduce it, it is probabilistic. It has happened only 6 times in the last week out of ~5000 /openapi requests.

bradydean commented 11 months ago

It definitely seems to be an issue with concurrent requests. I ran a stress test on /openapi with locust with 10 users, 1 user/s, for 1 minute and out of 268 requests, 60 failed.

I'm seeing the same errors I've already reported, but also a new one.

exception ``` Traceback (most recent call last): File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 534, in thread_handler raise exc_info[1] File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner response = await get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 534, in thread_handler raise exc_info[1] File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async response = await wrapped_callback( ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 479, in __call__ ret: _R = await loop.run_in_executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/current_thread_executor.py", line 40, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/asgiref/sync.py", line 538, in thread_handler return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper return view_func(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 48, in _wrapper return bound_method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/django/views/decorators/cache.py", line 54, in _view_wrapper response = viewfunc(request, *args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/views.py", line 84, in get return self._get_schema_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/views.py", line 92, in _get_schema_response data=generator.get_schema(request=request, public=self.serve_public), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/generators.py", line 281, in get_schema paths=self.parse(request, public), ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/generators.py", line 252, in parse operation = view.schema.get_operation( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/utils.py", line 424, in get_operation return super().get_operation(path, path_regex, path_prefix, method, registry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 99, in get_operation request_body = self._get_request_body() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 1295, in _get_request_body schema, partial_request_body_required = self._get_request_for_media_type(serializer, direction) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/app/.cache/pypoetry/virtualenvs/recovery-platform-BwZRr09X-py3.12/lib/python3.12/site-packages/drf_spectacular/openapi.py", line 1334, in _get_request_for_media_type p for p, s in component.schema.get('properties', {}).items() if s.get('readOnly') ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get' ```

With the stress test I can also reproduce it locally now, if there are any steps you want me to take to debug on my end let me know @tfranzel

tfranzel commented 11 months ago

I would like to debug this as close to your setup as possible. please, if possible, state as much context as possible, e.g.

I think it has to be somehow related to your concrete setup, because otherwise this should have been raised way more often, given the now widespread usage of drf-spectacular.

bradydean commented 11 months ago

Also, I just ran the stress test using gunicorn wsgi and had no errors. Maybe it's related to daphne asgi?

tfranzel commented 11 months ago

Thanks @bradydean for the detailed info. I will try to reproduce this over the holidays and will get back to you.

Maybe it's related to daphne asgi?

possibly...

Generally, my setups are very close to yours and I never encountered that problem. Also, daphne has never failed me like that. So in theory nothing wrong with your setup.

bradydean commented 11 months ago

Thanks for the help @tfranzel

I just tried gunicorn+uvicorn worker class and the errors appear again. Seems something is up with asgi. It works fine with the gevent worker class.