SentryAsgiMiddleware not compatible with Uvicorn 0.13.0
See original GitHub issueOn December 8th Uvicorn updated from 0.12.3 to 0.13.0. This results in an error at startup, see output with minimal example. When downgrading Uvicorn to 0.12.3 the example runs fine.
Why this error is thrown or which changes resulted in the error, I have no clue. Could you help me with this?
app.py
from sanic import Sanic
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
app = SentryAsgiMiddleware(Sanic(__name__))
requirements.txt
sanic==20.9.1
sentry-sdk==0.19.4
uvicorn==0.13.0
Command to run:
uvicorn app:app --port 5000 --workers=1 --debug --reload
Output:
INFO: Uvicorn running on http://127.0.0.1:5000 (Press CTRL+C to quit)
INFO: Started reloader process [614068] using statreload
Process SpawnProcess-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/lander/.local/share/virtualenvs/san-iJ5wdX60/lib/python3.9/site-packages/uvicorn/subprocess.py", line 61, in subprocess_started
target(sockets=sockets)
File "/home/lander/.local/share/virtualenvs/san-iJ5wdX60/lib/python3.9/site-packages/uvicorn/server.py", line 48, in run
loop.run_until_complete(self.serve(sockets=sockets))
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/home/lander/.local/share/virtualenvs/san-iJ5wdX60/lib/python3.9/site-packages/uvicorn/server.py", line 55, in serve
config.load()
File "/home/lander/.local/share/virtualenvs/san-iJ5wdX60/lib/python3.9/site-packages/uvicorn/config.py", line 319, in load
elif not inspect.signature(self.loaded_app).parameters:
File "/usr/lib/python3.9/inspect.py", line 3118, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/usr/lib/python3.9/inspect.py", line 2867, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File "/usr/lib/python3.9/inspect.py", line 2409, in _signature_from_callable
sig = _signature_from_callable(
File "/usr/lib/python3.9/inspect.py", line 2242, in _signature_from_callable
raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: <member '__call__' of 'SentryAsgiMiddleware' objects> is not a callable object
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:33 (9 by maintainers)
Top Results From Across the Web
Uvicorn
Uvicorn is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level server/application interface for async frameworks.
Read more >uvicorn - PyPI
Uvicorn is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level server/application interface for async ...
Read more >CHANGELOG.md · master · mirrors / getsentry / sentry-python ...
Fix an issue with the ASGI middleware that would cause Uvicorn to infer the wrong ASGI versions and call the wrapped application with...
Read more >sentry Changelog - PyUp.io
**Breaking Change**: This version introduces a change to the grouping of issues. The SDK now sets the `inApp` flag for frames originating from...
Read more >uvicorn is not working when called from the terminal
i recently install fastapi,uvicorn and tried to run. uvicorn main:app --reload. I am using zsh (shell type does not matter) and pyenv for ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this issue can be closed, after the implemented fixes.
It doesn’t, but due to the
__call__
trick the code that Uvicorn was using to decide whether an app was a factory or not was failing. 😃