Open Spirit412 opened 3 years ago
Looks like you misunderstood how Depends
works: it takes a Callable
which in turn provides the actual value you're depending on. For example:
def get_db():
try:
db = Database()
yield db
finally:
db.close()
Now, you'd use that like
def foo(db: Database = Depends(get_db), ...):
pass
I'm not sure if that's what's causing your memory issue, but it certainly isn't helping it.
I have a code where Depends is used in a class to implement methods of other classes. When the application is launched, this class takes up memoty more than 100Mb Here is an example:
How to optimize such code?
` class OrderFactory:
` The whole project is 2 MB. After the start of the project, 800MB of memory is used