Skip to content

Commit 92e3701

Browse files
committed
Fix uvicorn auto detection.
1 parent fd71136 commit 92e3701

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

newrelic/hooks/adapter_uvicorn.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
@property
1919
def loaded_app(self):
20+
# Always use the original application until the interface is resolved in
21+
# auto mode
22+
if getattr(self, "interface", "") == "auto":
23+
app = self._nr_loaded_app
24+
while hasattr(app, "__wrapped__"):
25+
app = app.__wrapped__
26+
return app
2027
return self._nr_loaded_app
2128

2229

tests/testing_support/sample_asgi_applications.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ async def static(scope, receive, send):
6363
return await simple_app_v3_raw(scope, receive, send)
6464

6565

66+
class AppWithCallRaw:
67+
async def __call__(self, scope, receive, send):
68+
return await simple_app_v3_raw(scope, receive, send)
69+
70+
71+
class AppWithCall(AppWithCallRaw):
72+
@ASGIApplicationWrapper
73+
async def __call__(self, scope, receive, send):
74+
return await super(AppWithCall, self).__call__(scope, receive, send)
75+
76+
6677
simple_app_v2 = ASGIApplicationWrapper(simple_app_v2_raw)
6778
simple_app_v2_init_exc = ASGIApplicationWrapper(simple_app_v2_init_exc)
6879
simple_app_v3 = ASGIApplicationWrapper(simple_app_v3_raw)

0 commit comments

Comments
 (0)