Remove dependency on requests library.

Change auto reloader enviroment varible name to SANIC_SERVER_RUNNING
Fix some typo mistakes, flake uncompatibilities and such problems.
Raise NotImplementedError for operating systems except posix systems for auto reloading.
This commit is contained in:
Yaser Amiri
2017-12-26 19:17:13 +03:30
parent 3fe3c2c79f
commit 81494453b0
8 changed files with 68 additions and 39 deletions

View File

@@ -645,8 +645,13 @@ class Sanic:
try:
self.is_running = True
if workers == 1:
if os.name == 'posix' and auto_reload and \
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
if auto_reload and os.name != 'posix':
# This condition must be removed after implementing
# auto reloader for other operating systems.
raise NotImplementedError
if auto_reload and \
os.environ.get('SANIC_SERVER_RUNNING') != 'true':
reloader_helpers.watchdog(2)
else:
serve(**server_settings)
@@ -808,14 +813,14 @@ class Sanic:
logger.setLevel(logging.DEBUG)
if self.config.LOGO is not None and \
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
os.environ.get('SANIC_SERVER_RUNNING') != 'true':
logger.debug(self.config.LOGO)
if run_async:
server_settings['run_async'] = True
# Serve
if host and port and os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
if host and port and os.environ.get('SANIC_SERVER_RUNNING') != 'true':
proto = "http"
if ssl is not None:
proto = "https"