app.run and app.create_server argument fixup.

This commit is contained in:
L. Kärkkäinen 2020-03-31 14:51:30 +03:00
parent d04fbfc9bf
commit 261d15e327

View File

@ -1060,7 +1060,9 @@ class Sanic:
self, self,
host: Optional[str] = None, host: Optional[str] = None,
port: Optional[int] = None, port: Optional[int] = None,
*,
debug: bool = False, debug: bool = False,
auto_reload: Optional[bool] = None,
ssl: Union[dict, SSLContext, None] = None, ssl: Union[dict, SSLContext, None] = None,
sock: Optional[socket] = None, sock: Optional[socket] = None,
workers: int = 1, workers: int = 1,
@ -1069,7 +1071,7 @@ class Sanic:
stop_event: Any = None, stop_event: Any = None,
register_sys_signals: bool = True, register_sys_signals: bool = True,
access_log: Optional[bool] = None, access_log: Optional[bool] = None,
**kwargs: Any, loop: None = None,
) -> None: ) -> None:
"""Run the HTTP Server and listen until keyboard interrupt or term """Run the HTTP Server and listen until keyboard interrupt or term
signal. On termination, drain connections before closing. signal. On termination, drain connections before closing.
@ -1080,6 +1082,9 @@ class Sanic:
:type port: int :type port: int
:param debug: Enables debug output (slows server) :param debug: Enables debug output (slows server)
:type debug: bool :type debug: bool
:param auto_reload: Reload app whenever its source code is changed.
Enabled by default in debug mode.
:type auto_relaod: bool
:param ssl: SSLContext, or location of certificate and key :param ssl: SSLContext, or location of certificate and key
for SSL encryption of worker(s) for SSL encryption of worker(s)
:type ssl: SSLContext or dict :type ssl: SSLContext or dict
@ -1101,7 +1106,7 @@ class Sanic:
:type access_log: bool :type access_log: bool
:return: Nothing :return: Nothing
""" """
if "loop" in kwargs: if loop is not None:
raise TypeError( raise TypeError(
"loop is not a valid argument. To use an existing loop, " "loop is not a valid argument. To use an existing loop, "
"change to create_server().\nSee more: " "change to create_server().\nSee more: "
@ -1109,15 +1114,7 @@ class Sanic:
"#asynchronous-support" "#asynchronous-support"
) )
# Default auto_reload to false if auto_reload or auto_reload is None and debug:
auto_reload = False
# If debug is set, default it to true (unless on windows)
if debug and os.name == "posix":
auto_reload = True
# Allow for overriding either of the defaults
auto_reload = kwargs.get("auto_reload", auto_reload)
if auto_reload:
if os.environ.get("SANIC_SERVER_RUNNING") != "true": if os.environ.get("SANIC_SERVER_RUNNING") != "true":
return reloader_helpers.watchdog(2) return reloader_helpers.watchdog(2)
@ -1184,6 +1181,7 @@ class Sanic:
self, self,
host: Optional[str] = None, host: Optional[str] = None,
port: Optional[int] = None, port: Optional[int] = None,
*,
debug: bool = False, debug: bool = False,
ssl: Union[dict, SSLContext, None] = None, ssl: Union[dict, SSLContext, None] = None,
sock: Optional[socket] = None, sock: Optional[socket] = None,