Merge pull request #359 from r0fls/fix-warnings
fix deprecation warnings
This commit is contained in:
commit
7257e5794f
|
@ -4,6 +4,7 @@ from collections import deque
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from inspect import isawaitable, stack, getmodulename
|
from inspect import isawaitable, stack, getmodulename
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
|
import warnings
|
||||||
|
|
||||||
from .config import Config
|
from .config import Config
|
||||||
from .exceptions import Handler
|
from .exceptions import Handler
|
||||||
|
@ -175,9 +176,12 @@ class Sanic:
|
||||||
|
|
||||||
def register_blueprint(self, *args, **kwargs):
|
def register_blueprint(self, *args, **kwargs):
|
||||||
# TODO: deprecate 1.0
|
# TODO: deprecate 1.0
|
||||||
log.warning("Use of register_blueprint will be deprecated in "
|
if self.debug:
|
||||||
"version 1.0. Please use the blueprint method instead",
|
warnings.simplefilter('default')
|
||||||
DeprecationWarning)
|
warnings.warn("Use of register_blueprint will be deprecated in "
|
||||||
|
"version 1.0. Please use the blueprint method"
|
||||||
|
" instead",
|
||||||
|
DeprecationWarning)
|
||||||
return self.blueprint(*args, **kwargs)
|
return self.blueprint(*args, **kwargs)
|
||||||
|
|
||||||
# -------------------------------------------------------------------- #
|
# -------------------------------------------------------------------- #
|
||||||
|
@ -296,12 +300,16 @@ class Sanic:
|
||||||
"""
|
"""
|
||||||
self.error_handler.debug = debug
|
self.error_handler.debug = debug
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
if loop is not None:
|
|
||||||
log.warning("Passing a loop will be deprecated in version 0.4.0"
|
|
||||||
" https://github.com/channelcat/sanic/pull/335"
|
|
||||||
" has more information.", DeprecationWarning)
|
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
|
|
||||||
|
if loop is not None:
|
||||||
|
if self.debug:
|
||||||
|
warnings.simplefilter('default')
|
||||||
|
warnings.warn("Passing a loop will be deprecated in version"
|
||||||
|
" 0.4.0 https://github.com/channelcat/sanic/"
|
||||||
|
"pull/335 has more information.",
|
||||||
|
DeprecationWarning)
|
||||||
|
|
||||||
server_settings = {
|
server_settings = {
|
||||||
'protocol': protocol,
|
'protocol': protocol,
|
||||||
'host': host,
|
'host': host,
|
||||||
|
@ -375,9 +383,13 @@ class Sanic:
|
||||||
Asynchronous version of `run`.
|
Asynchronous version of `run`.
|
||||||
"""
|
"""
|
||||||
if loop is not None:
|
if loop is not None:
|
||||||
log.warning("Passing a loop will be deprecated in version 0.4.0"
|
if self.debug:
|
||||||
" https://github.com/channelcat/sanic/pull/335"
|
warnings.simplefilter('default')
|
||||||
" has more information.", DeprecationWarning)
|
warnings.warn("Passing a loop will be deprecated in version"
|
||||||
|
" 0.4.0 https://github.com/channelcat/sanic/"
|
||||||
|
"pull/335 has more information.",
|
||||||
|
DeprecationWarning)
|
||||||
|
|
||||||
loop = get_event_loop()
|
loop = get_event_loop()
|
||||||
server_settings = {
|
server_settings = {
|
||||||
'protocol': protocol,
|
'protocol': protocol,
|
||||||
|
|
|
@ -9,6 +9,7 @@ from signal import SIGTERM, SIGINT
|
||||||
from signal import signal as signal_func
|
from signal import signal as signal_func
|
||||||
from socket import socket, SOL_SOCKET, SO_REUSEADDR
|
from socket import socket, SOL_SOCKET, SO_REUSEADDR
|
||||||
from time import time
|
from time import time
|
||||||
|
import warnings
|
||||||
|
|
||||||
from httptools import HttpRequestParser
|
from httptools import HttpRequestParser
|
||||||
from httptools.parser.errors import HttpParserError
|
from httptools.parser.errors import HttpParserError
|
||||||
|
@ -384,9 +385,11 @@ def serve_multiple(server_settings, workers, stop_event=None):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if server_settings.get('loop', None) is not None:
|
if server_settings.get('loop', None) is not None:
|
||||||
log.warning("Passing a loop will be deprecated in version 0.4.0"
|
if server_settings.get('debug', False):
|
||||||
" https://github.com/channelcat/sanic/pull/335"
|
warnings.simplefilter('default')
|
||||||
" has more information.", DeprecationWarning)
|
warnings.warn("Passing a loop will be deprecated in version 0.4.0"
|
||||||
|
" https://github.com/channelcat/sanic/pull/335"
|
||||||
|
" has more information.", DeprecationWarning)
|
||||||
server_settings['reuse_port'] = True
|
server_settings['reuse_port'] = True
|
||||||
|
|
||||||
sock = socket()
|
sock = socket()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user