fix deprecation warnings
This commit is contained in:
parent
3d790a71a0
commit
0eb779185d
|
@ -4,6 +4,7 @@ from collections import deque
|
|||
from functools import partial
|
||||
from inspect import isawaitable, stack, getmodulename
|
||||
from traceback import format_exc
|
||||
import warnings
|
||||
|
||||
from .config import Config
|
||||
from .exceptions import Handler
|
||||
|
@ -175,8 +176,11 @@ class Sanic:
|
|||
|
||||
def register_blueprint(self, *args, **kwargs):
|
||||
# TODO: deprecate 1.0
|
||||
log.warning("Use of register_blueprint will be deprecated in "
|
||||
"version 1.0. Please use the blueprint method instead",
|
||||
if self.debug:
|
||||
warnings.simplefilter('default')
|
||||
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)
|
||||
|
||||
|
@ -296,12 +300,16 @@ class Sanic:
|
|||
"""
|
||||
self.error_handler.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
|
||||
|
||||
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 = {
|
||||
'protocol': protocol,
|
||||
'host': host,
|
||||
|
@ -375,9 +383,13 @@ class Sanic:
|
|||
Asynchronous version of `run`.
|
||||
"""
|
||||
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)
|
||||
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)
|
||||
|
||||
loop = get_event_loop()
|
||||
server_settings = {
|
||||
'protocol': protocol,
|
||||
|
|
|
@ -9,6 +9,7 @@ from signal import SIGTERM, SIGINT
|
|||
from signal import signal as signal_func
|
||||
from socket import socket, SOL_SOCKET, SO_REUSEADDR
|
||||
from time import time
|
||||
import warnings
|
||||
|
||||
from httptools import HttpRequestParser
|
||||
from httptools.parser.errors import HttpParserError
|
||||
|
@ -384,7 +385,9 @@ def serve_multiple(server_settings, workers, stop_event=None):
|
|||
:return:
|
||||
"""
|
||||
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):
|
||||
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['reuse_port'] = True
|
||||
|
|
Loading…
Reference in New Issue
Block a user