Jump to solution
Verify

The Fix

Upgrade to version 0.13.3 or later.

Based on closed Kludex/uvicorn issue #900 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@ import json +import logging import socket from copy import deepcopy
repro.py
>> class Middleware: ... def __init__(self): ... self.__call__ = self._run ... def _run(self): pass ... >> m = Middleware() >> import inspect >> inspect.signature(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 3118, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped) File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2867, in from_callable return _signature_from_callable(obj, sigcls=cls, File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2242, in _signature_from_callable raise TypeError('{!r} is not a callable object'.format(obj)) TypeError: <__main__.Middleware object at 0x10f4dbb20> is not a callable object
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.13.3 or later.\nWhen NOT to use: This fix is not suitable for applications that require strict ASGI 2 compatibility.\n\n

Why This Fix Works in Production

  • Trigger: raise TypeError('{!r} is not a callable object'.format(obj))
  • Mechanism: The introspection of the callable fails to recognize method objects due to dynamic assignment of the __call__ method
  • Why the fix works: Tweak detection of app factories to avoid issues with SentryAsgiMiddleware. (first fixed release: 0.13.3).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.7 in real deployments (not just unit tests).
  • The introspection of the callable fails to recognize method objects due to dynamic assignment of the __call__ method
  • Surfaces as: File "/usr/lib/python3.7/inspect.py", line 2208, in _signature_from_callable

Proof / Evidence

  • GitHub issue: #900
  • Fix PR: https://github.com/kludex/uvicorn/pull/914
  • First fixed release: 0.13.3
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.39

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“To be clear AFAICT the bug here is not related to determining ASGI 2 vs ASGI 3, but related to "app instances" vs "app factories"”
@florimondmanca · 2020-12-19 · source
“Hm, being an old school Python guy, I probably would have opted for just calling the object, without an argument, and if that worked, assume…”
@kristjanvalur · 2020-12-21 · source
“Perhaps having a subclass of UvicornWorker that just assumes asgi3 and doesn't try to second-guess the protocol from the callable”
@kristjanvalur · 2020-12-18 · source
“this seems more like an issue introduced in #875”
@euri10 · 2020-12-19 · source

Failure Signature (Search String)

  • raise TypeError('{!r} is not a callable object'.format(obj))

Error Message

Stack trace
error.txt
Error Message ------------- File "/usr/lib/python3.7/inspect.py", line 2208, in _signature_from_callable raise TypeError('{!r} is not a callable object'.format(obj))
Stack trace
error.txt
Error Message ------------- TypeError: _run_asgi3() missing 2 required positional arguments: 'receive' and 'send'
Stack trace
error.txt
Error Message ------------- >> class Middleware: ... def __init__(self): ... self.__call__ = self._run ... def _run(self): pass ... >> m = Middleware() >> import inspect >> inspect.signature(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 3118, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped) File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2867, in from_callable return _signature_from_callable(obj, sigcls=cls, File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2242, in _signature_from_callable raise TypeError('{!r} is not a callable object'.format(obj)) TypeError: <__main__.Middleware object at 0x10f4dbb20> is not a callable object

Minimal Reproduction

repro.py
>> class Middleware: ... def __init__(self): ... self.__call__ = self._run ... def _run(self): pass ... >> m = Middleware() >> import inspect >> inspect.signature(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 3118, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped) File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2867, in from_callable return _signature_from_callable(obj, sigcls=cls, File "/Users/florimond/.pyenv/versions/3.9.0/lib/python3.9/inspect.py", line 2242, in _signature_from_callable raise TypeError('{!r} is not a callable object'.format(obj)) TypeError: <__main__.Middleware object at 0x10f4dbb20> is not a callable object

Environment

  • Python: 3.7

What Broke

Application fails to launch or handle requests, resulting in TypeErrors.

Why It Broke

The introspection of the callable fails to recognize method objects due to dynamic assignment of the __call__ method

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.13.3 or later.

When NOT to use: This fix is not suitable for applications that require strict ASGI 2 compatibility.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/kludex/uvicorn/pull/914

First fixed release: 0.13.3

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not suitable for applications that require strict ASGI 2 compatibility.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
0.13.3 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.