mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Update Tornado Web Server 5.0.1 (35a538f) → 5.0.1 (2b2a220a).
This commit is contained in:
parent
179f54f2be
commit
65923c94ef
4 changed files with 24 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
### 0.17.0 (2018-xx-xx xx:xx:xx UTC)
|
### 0.17.0 (2018-xx-xx xx:xx:xx UTC)
|
||||||
|
|
||||||
|
* Update Tornado Web Server 5.0.1 (35a538f) to 5.0.1 (2b2a220a)
|
||||||
|
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
|
|
|
@ -47,6 +47,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import math
|
import math
|
||||||
|
import random
|
||||||
|
|
||||||
from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info, future_add_done_callback # noqa: E501
|
from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info, future_add_done_callback # noqa: E501
|
||||||
from tornado.log import app_log, gen_log
|
from tornado.log import app_log, gen_log
|
||||||
|
@ -1161,6 +1162,14 @@ class PeriodicCallback(object):
|
||||||
Note that the timeout is given in milliseconds, while most other
|
Note that the timeout is given in milliseconds, while most other
|
||||||
time-related functions in Tornado use seconds.
|
time-related functions in Tornado use seconds.
|
||||||
|
|
||||||
|
If ``jitter`` is specified, each callback time will be randomly selected
|
||||||
|
within a window of ``jitter * callback_time`` milliseconds.
|
||||||
|
Jitter can be used to reduce alignment of events with similar periods.
|
||||||
|
A jitter of 0.1 means allowing a 10% variation in callback time.
|
||||||
|
The window is centered on ``callback_time`` so the total number of calls
|
||||||
|
within a given interval should not be significantly affected by adding
|
||||||
|
jitter.
|
||||||
|
|
||||||
If the callback runs for longer than ``callback_time`` milliseconds,
|
If the callback runs for longer than ``callback_time`` milliseconds,
|
||||||
subsequent invocations will be skipped to get back on schedule.
|
subsequent invocations will be skipped to get back on schedule.
|
||||||
|
|
||||||
|
@ -1168,12 +1177,16 @@ class PeriodicCallback(object):
|
||||||
|
|
||||||
.. versionchanged:: 5.0
|
.. versionchanged:: 5.0
|
||||||
The ``io_loop`` argument (deprecated since version 4.1) has been removed.
|
The ``io_loop`` argument (deprecated since version 4.1) has been removed.
|
||||||
|
|
||||||
|
.. versionchanged:: 5.1
|
||||||
|
The ``jitter`` argument is added.
|
||||||
"""
|
"""
|
||||||
def __init__(self, callback, callback_time):
|
def __init__(self, callback, callback_time, jitter=0):
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
if callback_time <= 0:
|
if callback_time <= 0:
|
||||||
raise ValueError("Periodic callback must have a positive callback_time")
|
raise ValueError("Periodic callback must have a positive callback_time")
|
||||||
self.callback_time = callback_time
|
self.callback_time = callback_time
|
||||||
|
self.jitter = jitter
|
||||||
self._running = False
|
self._running = False
|
||||||
self._timeout = None
|
self._timeout = None
|
||||||
|
|
||||||
|
@ -1218,6 +1231,9 @@ class PeriodicCallback(object):
|
||||||
|
|
||||||
def _update_next(self, current_time):
|
def _update_next(self, current_time):
|
||||||
callback_time_sec = self.callback_time / 1000.0
|
callback_time_sec = self.callback_time / 1000.0
|
||||||
|
if self.jitter:
|
||||||
|
# apply jitter fraction
|
||||||
|
callback_time_sec *= 1 + (self.jitter * (random.random() - 0.5))
|
||||||
if self._next_timeout <= current_time:
|
if self._next_timeout <= current_time:
|
||||||
# The period should be measured from the start of one call
|
# The period should be measured from the start of one call
|
||||||
# to the start of the next. If one call takes too long,
|
# to the start of the next. If one call takes too long,
|
||||||
|
|
|
@ -2825,6 +2825,7 @@ class FallbackHandler(RequestHandler):
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
self.fallback(self.request)
|
self.fallback(self.request)
|
||||||
self._finished = True
|
self._finished = True
|
||||||
|
self.on_finish()
|
||||||
|
|
||||||
|
|
||||||
class OutputTransform(object):
|
class OutputTransform(object):
|
||||||
|
|
|
@ -19,7 +19,6 @@ the protocol (known as "draft 76") and are not compatible with this module.
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import collections
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
@ -34,6 +33,7 @@ from tornado.ioloop import IOLoop, PeriodicCallback
|
||||||
from tornado.iostream import StreamClosedError
|
from tornado.iostream import StreamClosedError
|
||||||
from tornado.log import gen_log, app_log
|
from tornado.log import gen_log, app_log
|
||||||
from tornado import simple_httpclient
|
from tornado import simple_httpclient
|
||||||
|
from tornado.queues import Queue
|
||||||
from tornado.tcpclient import TCPClient
|
from tornado.tcpclient import TCPClient
|
||||||
from tornado.util import _websocket_mask, PY3
|
from tornado.util import _websocket_mask, PY3
|
||||||
|
|
||||||
|
@ -1096,8 +1096,7 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection):
|
||||||
self.compression_options = compression_options
|
self.compression_options = compression_options
|
||||||
self.connect_future = Future()
|
self.connect_future = Future()
|
||||||
self.protocol = None
|
self.protocol = None
|
||||||
self.read_future = None
|
self.read_queue = Queue(1)
|
||||||
self.read_queue = collections.deque()
|
|
||||||
self.key = base64.b64encode(os.urandom(16))
|
self.key = base64.b64encode(os.urandom(16))
|
||||||
self._on_message_callback = on_message_callback
|
self._on_message_callback = on_message_callback
|
||||||
self.close_code = self.close_reason = None
|
self.close_code = self.close_reason = None
|
||||||
|
@ -1207,12 +1206,8 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection):
|
||||||
is given it will be called with the future when it is
|
is given it will be called with the future when it is
|
||||||
ready.
|
ready.
|
||||||
"""
|
"""
|
||||||
assert self.read_future is None
|
|
||||||
future = Future()
|
future = self.read_queue.get()
|
||||||
if self.read_queue:
|
|
||||||
future_set_result_unless_cancelled(future, self.read_queue.popleft())
|
|
||||||
else:
|
|
||||||
self.read_future = future
|
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
self.io_loop.add_future(future, callback)
|
self.io_loop.add_future(future, callback)
|
||||||
return future
|
return future
|
||||||
|
@ -1220,11 +1215,8 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection):
|
||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
if self._on_message_callback:
|
if self._on_message_callback:
|
||||||
self._on_message_callback(message)
|
self._on_message_callback(message)
|
||||||
elif self.read_future is not None:
|
|
||||||
future_set_result_unless_cancelled(self.read_future, message)
|
|
||||||
self.read_future = None
|
|
||||||
else:
|
else:
|
||||||
self.read_queue.append(message)
|
return self.read_queue.put(message)
|
||||||
|
|
||||||
def ping(self, data=b''):
|
def ping(self, data=b''):
|
||||||
"""Send ping frame to the remote end.
|
"""Send ping frame to the remote end.
|
||||||
|
|
Loading…
Reference in a new issue