Skip to content

fix: fix Django ASGI integration on Python 3.12#3027

Merged
sentrivana merged 3 commits into
getsentry:masterfrom
bellini666:master
Apr 30, 2024
Merged

fix: fix Django ASGI integration on Python 3.12#3027
sentrivana merged 3 commits into
getsentry:masterfrom
bellini666:master

Conversation

@bellini666

Copy link
Copy Markdown
Contributor

Upgrading a Django ASGI application to Python 3.12 broke because of the integration not being able to identify that the middleware being called was async.

This is due to Python 3.12 replacing setting _is_coroutine = asyncio.coroutines._is_coroutine with inspect.markcoroutinefunction

This ports the fix from asgiref to make sure sentry_sdk can support multiple python versions.

I thought about importing it from asgiref, but not sure how the maintainers feel about requiring it as a dependency (although it is already a django's dependency)

@sentrivana

Copy link
Copy Markdown
Contributor

Hey @bellini666, thanks a lot for the fix! Taking a look.

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I also think porting the asgiref shim is a good way to go about this, even if asgiref is a Django dependency.

Thanks again for the fix, will merge this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants