-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Added use_subprocess to be more generic"
This reverts commit d1b5f83
- Loading branch information
Showing
4 changed files
with
26 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import asyncio | ||
import logging | ||
import sys | ||
from typing import Optional | ||
|
||
logger = logging.getLogger("uvicorn.error") | ||
|
||
|
||
def asyncio_setup(use_subprocess: bool = False) -> None: # pragma: no cover | ||
if sys.version_info >= (3, 8) and sys.platform == "win32" and use_subprocess: | ||
logger.warning("The --reload flag should not be used in production on Windows.") | ||
def asyncio_setup( | ||
reload: bool = False, workers: Optional[int] = None | ||
) -> None: # pragma: no cover | ||
if ( | ||
sys.version_info >= (3, 8) | ||
and sys.platform == "win32" | ||
and any([reload, workers]) | ||
): | ||
if reload: | ||
logger.warning( | ||
"The --reload flag should not be used in production on Windows." | ||
) | ||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) |
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,11 +1,14 @@ | ||
def auto_loop_setup(use_subprocess: bool = False) -> None: | ||
from typing import Optional | ||
|
||
|
||
def auto_loop_setup(reload: bool = False, workers: Optional[int] = None) -> None: | ||
try: | ||
import uvloop # noqa | ||
except ImportError: # pragma: no cover | ||
from uvicorn.loops.asyncio import asyncio_setup as loop_setup | ||
|
||
loop_setup(use_subprocess=use_subprocess) | ||
loop_setup(reload=reload, workers=workers) | ||
else: # pragma: no cover | ||
from uvicorn.loops.uvloop import uvloop_setup | ||
|
||
uvloop_setup(use_subprocess=use_subprocess) | ||
uvloop_setup(reload=reload, workers=workers) |
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,7 +1,8 @@ | ||
import asyncio | ||
from typing import Optional | ||
|
||
import uvloop | ||
|
||
|
||
def uvloop_setup(use_subprocess: bool = False) -> None: | ||
def uvloop_setup(reload: bool = False, workers: Optional[int] = None) -> None: | ||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) |