<@U02SS3ZAMKQ> We have asyncio loop stuff for grap...
# support
@Prashant Shahi We have asyncio loop stuff for graphdb interactions in our main backend, which is why we were using
Copy code
CMD ["uvicorn", "--workers", "2", "--host", "", "--port", "8000", "--ws", "websockets", "--loop", "asyncio", "--ws-max-size", "100000", "--ws-ping-interval", "20.00", "--ws-ping-timeout", "20.00", "wombo.fastapi:app"]
However, Uvicorn can't be used because https://github.com/open-telemetry/opentelemetry-python-contrib/issues/385#issuecomment-1199088668, so as per your suggestion we migrated to
Copy code
CMD opentelemetry-instrument --traces_exporter otlp_proto_grpc gunicorn wombo.fastapi:app --workers 2 --worker-class  uvicorn.workers.UvicornWorker --bind
But this forced us to disable
Copy code
Which inturn breaks a lot of our operations. Do you have any suggestions? I tried into seeing if i could use other worker classes like
for gunicorn https://docs.gunicorn.org/en/latest/design.html#async-workers However they are giving monkey_patch errors which I can't initialize before
Using https://docs.aiohttp.org/en/stable/deployment.html#start-gunicorn gives
Copy code
[2022-10-27 21:55:00 +0000] [20] [INFO] Worker exiting (pid: 20)
[2022-10-27 21:55:00 +0000] [12] [ERROR] Exception in gunicorn worker
Traceback (most recent call last):
  File "/opt/venv/lib/python3.9/site-packages/aiohttp/worker.py", line 57, in run
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/opt/venv/lib/python3.9/site-packages/aiohttp/worker.py", line 77, in _run
    raise RuntimeError(
RuntimeError: wsgi app should be either Application or async function returning Application, got <opentelemetry.instrumentation.fastapi._InstrumentedFastAPI object at 0x7f3f5b212fa0>
This is a no-win situation, Gunicorn with UvicornH11Worker has the same trouble of uvicorn with multiple workers
it doesn't send GRPC
and normal UnicornWorker doesn't allow asyncio operations for me
@Srikanth Chekuri should have the most insights on this
@Srikanth Chekuri can you please help Abhinav configure python instrumentation when you get some time?
A lot of this info is contextual to your application codebase so I won’t be much helpful. You have two options either use gunicorn with worker class which seems to be not so great given other things about your codebase or just use single worker with uvicorn which I think is the best option here.
can we sync , there should be some better solution, if I understand problem properly maybe I can try a custom gunicorn class or something
whenever u are free LMK
if I understand problem properly maybe I can try a custom gunicorn class or something
You are the best person to do this because you work with the codebase and know why certain libraries were and how they are conflicting here.
whenever u are free LMK
Before we do this, if you can share me minimal app which has the problem I can probably spend some understanding what is happening and see what can be done about it.
@Abhinav Ramana if you haven’t already seen these docs here is the official recommendation and options to extend using subclasses https://www.uvicorn.org/deployment/#gunicorn.