-
-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazy load Reload and Multiprocess supervisors
- Loading branch information
Mickaël Guérin
committed
Jan 14, 2023
1 parent
e35b34f
commit 79becec
Showing
4 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
from typing import TYPE_CHECKING, Type | ||
|
||
from uvicorn.supervisors.basereload import BaseReload | ||
from uvicorn.supervisors.multiprocess import Multiprocess | ||
|
||
if TYPE_CHECKING: | ||
ChangeReload: Type[BaseReload] | ||
else: | ||
from uvicorn.supervisors.basereload import BaseReload | ||
|
||
|
||
def get_reload_class() -> "Type[BaseReload]": | ||
try: | ||
from uvicorn.supervisors.watchfilesreload import ( | ||
WatchFilesReload as ChangeReload, | ||
) | ||
from uvicorn.supervisors.watchfilesreload import WatchFilesReload | ||
|
||
return WatchFilesReload | ||
except ImportError: # pragma: no cover | ||
try: | ||
from uvicorn.supervisors.watchgodreload import ( | ||
WatchGodReload as ChangeReload, | ||
) | ||
from uvicorn.supervisors.watchgodreload import WatchGodReload | ||
|
||
return WatchGodReload | ||
except ImportError: | ||
from uvicorn.supervisors.statreload import StatReload as ChangeReload | ||
from uvicorn.supervisors.statreload import StatReload | ||
|
||
return StatReload | ||
|
||
|
||
__all__ = ["Multiprocess", "ChangeReload"] | ||
__all__ = ["get_reload_class"] |