Fast API Websocket coroutines throw attribute error when run with newrelic admin
sankarpa opened this issue · 5 comments
Description
I am using newrelic agent 8.5.0 with my fastapi which houses both rest and websocket apis. The app get deployed in kubernetes and here is how the container command looks like
containers:
- name: a-service
image: 'a-service:latest'
command:
- newrelic-admin
- run-program
- uvicorn
- app.main:app
- --port=8000
- --host=0.0.0.0
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "500m"
ports:
- containerPort: 8000
protocol: TCP
The container comes up healthy and runs , but the coroutines throws error with attribute not found error when calling async functions. The same is working fine when i run the container without newrelic-admin
Hello,
Could you perhaps supply a reproduction or at least some more specifics?
I was unable to reproduce any issue with the latest version of the agent. FastAPI has a minimalist example that I ran some testing against. I was using an async websocket endpoint and both sync and async HTTP routes were working alongside it with no issues.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi @Ak-x @TimPansino Sorry for responding late, I am using aioredis pubsub in the websocket functions and the code looks like below.
pubsub = redis.pubsub()
await pubsub.subscribe(f"{channel_id}")
await websocket.accept()
if I don't use newrelic agent , the subscribe function call works fine .
I get below error if I initialise the newrelic agent and connect to the websocket
AttributeError: 'coroutine' object has no attribute 'subscribe'
@TimPansino Any updates on this?