ets-labs / python-dependency-injector

Dependency injection framework for Python
https://python-dependency-injector.ets-labs.org/
BSD 3-Clause "New" or "Revised" License
3.83k stars 304 forks source link

injection is not working uWSGI + nginx + plotly dash + Flask #682

Open biyani701 opened 1 year ago

biyani701 commented 1 year ago

i have used dependency_injector and injecting DynamicContainer. It is working fine on local machine or if i run it with python3 wsgi.py on ubuntu machine.

But when running it with nginx on ubuntu using uwsgi the dynamic injection does not work. Below is my

index.ini [uwsgi] module = wsgi master = true processes = 4 socket = index.sock chmod-socket = 777 vacuum = true die-on-term = true chdir = /opt/project env = .env debug = true logto = /var/log/uwsgi/uwsgi.log log-4xx = true log-5xx = true

Any guidance will be really helpful to troubleshoot.

dimentii commented 1 year ago

I have exactly same issue while using gunicorn

dimentii commented 1 year ago

I have exactly same issue while using gunicorn

my bad had an initialization of container within if __name__ == '__main__': block

biyani701 commented 1 year ago

I did the exact same mistake. Your hint helped me resolve my problem as well :-) I think there should be a better way to debug wiring issue as this looks like a black box.