Is it somehow possible to exclude certain part of the code when reloading the scrip with --reload
flag?
uvicorn main:app --reload
Use case: I have a model which takes a lot of time loading so I was wondering if there is a way to ignore that line of code when reloading. Or is it just impossible?
Update
Uvicorn now supports including/excluding certain directories/files to/from watchlist.
--reload-include TEXT Set glob patterns to include while watching
for files. Includes '*.py' by default, which
can be overridden in reload-excludes.
--reload-exclude TEXT Set glob patterns to exclude while watching
for files. Includes '.*, .py[cod], .sw.*,
~*' by default, which can be overridden in
reload-excludes.
No there is no way to exclude something, however you can be explicit in what you want to be looked at with the --reload-dir
flag:
--reload-dir TEXT Set reload directories explicitly, instead
of using the current working directory.
in https://www.uvicorn.org/#command-line-options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With