python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

Eager provider/container initialization

Open cpvandehey opened this issue 2 years ago • 1 comments
trafficstars

Im curious if there is a reason that "lazily" loading dependencies is the only way to load any kind of provider (with the exception of Resources)

I think it makes sense to fail fast with regards to dependencies. For example: If there is a connection issue in a dependency that makes a web request on creation, i'd rather my app fail immediately than N amount of time later when that dependency is used.

Im writing this issue to see if other folks have written workarounds to eagerly initialize all of a projects dependency at Container creation time. Or maybe there is a good reason to avoid this. Its certainly standard to eagerly load dependencies in Java Spring.

There is a traversal method that is available that could make the manual way doing this a little easier.

cpvandehey avatar Mar 14 '23 01:03 cpvandehey