Skip to content

Commit

Permalink
Fix uvicorn auto detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-feld committed Sep 15, 2020
1 parent fd71136 commit 92e3701
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions newrelic/hooks/adapter_uvicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

@property
def loaded_app(self):
# Always use the original application until the interface is resolved in
# auto mode
if getattr(self, "interface", "") == "auto":
app = self._nr_loaded_app
while hasattr(app, "__wrapped__"):
app = app.__wrapped__
return app
return self._nr_loaded_app


Expand Down
11 changes: 11 additions & 0 deletions tests/testing_support/sample_asgi_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ async def static(scope, receive, send):
return await simple_app_v3_raw(scope, receive, send)


class AppWithCallRaw:
async def __call__(self, scope, receive, send):
return await simple_app_v3_raw(scope, receive, send)


class AppWithCall(AppWithCallRaw):
@ASGIApplicationWrapper
async def __call__(self, scope, receive, send):
return await super(AppWithCall, self).__call__(scope, receive, send)


simple_app_v2 = ASGIApplicationWrapper(simple_app_v2_raw)
simple_app_v2_init_exc = ASGIApplicationWrapper(simple_app_v2_init_exc)
simple_app_v3 = ASGIApplicationWrapper(simple_app_v3_raw)
Expand Down

0 comments on commit 92e3701

Please sign in to comment.