mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 05:13:21 -07:00
Update cherrypy-18.6.1
This commit is contained in:
parent
b3ae6bd695
commit
ebffd124f6
57 changed files with 1269 additions and 1509 deletions
|
@ -6,11 +6,10 @@ import signal as _signal
|
|||
import sys
|
||||
import time
|
||||
import threading
|
||||
|
||||
from six.moves import _thread
|
||||
import _thread
|
||||
|
||||
from cherrypy._cpcompat import text_or_bytes
|
||||
from cherrypy._cpcompat import ntob, Timer
|
||||
from cherrypy._cpcompat import ntob
|
||||
|
||||
# _module__file__base is used by Autoreload to make
|
||||
# absolute any filenames retrieved from sys.modules which are not
|
||||
|
@ -367,7 +366,7 @@ class Daemonizer(SimplePlugin):
|
|||
# "The general problem with making fork() work in a multi-threaded
|
||||
# world is what to do with all of the threads..."
|
||||
# So we check for active threads:
|
||||
if threading.activeCount() != 1:
|
||||
if threading.active_count() != 1:
|
||||
self.bus.log('There are %r active threads. '
|
||||
'Daemonizing now may cause strange failures.' %
|
||||
threading.enumerate(), level=30)
|
||||
|
@ -452,7 +451,7 @@ class PIDFile(SimplePlugin):
|
|||
pass
|
||||
|
||||
|
||||
class PerpetualTimer(Timer):
|
||||
class PerpetualTimer(threading.Timer):
|
||||
|
||||
"""A responsive subclass of threading.Timer whose run() method repeats.
|
||||
|
||||
|
@ -553,7 +552,7 @@ class Monitor(SimplePlugin):
|
|||
if self.thread is None:
|
||||
self.thread = BackgroundTask(self.frequency, self.callback,
|
||||
bus=self.bus)
|
||||
self.thread.setName(threadname)
|
||||
self.thread.name = threadname
|
||||
self.thread.start()
|
||||
self.bus.log('Started monitor thread %r.' % threadname)
|
||||
else:
|
||||
|
@ -566,8 +565,8 @@ class Monitor(SimplePlugin):
|
|||
self.bus.log('No thread running for %s.' %
|
||||
self.name or self.__class__.__name__)
|
||||
else:
|
||||
if self.thread is not threading.currentThread():
|
||||
name = self.thread.getName()
|
||||
if self.thread is not threading.current_thread():
|
||||
name = self.thread.name
|
||||
self.thread.cancel()
|
||||
if not self.thread.daemon:
|
||||
self.bus.log('Joining %r' % name)
|
||||
|
@ -627,7 +626,10 @@ class Autoreloader(Monitor):
|
|||
|
||||
def sysfiles(self):
|
||||
"""Return a Set of sys.modules filenames to monitor."""
|
||||
search_mod_names = filter(re.compile(self.match).match, sys.modules)
|
||||
search_mod_names = filter(
|
||||
re.compile(self.match).match,
|
||||
list(sys.modules.keys()),
|
||||
)
|
||||
mods = map(sys.modules.get, search_mod_names)
|
||||
return set(filter(None, map(self._file_for_module, mods)))
|
||||
|
||||
|
@ -690,7 +692,7 @@ class Autoreloader(Monitor):
|
|||
filename)
|
||||
self.thread.cancel()
|
||||
self.bus.log('Stopped thread %r.' %
|
||||
self.thread.getName())
|
||||
self.thread.name)
|
||||
self.bus.restart()
|
||||
return
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ class ServerAdapter(object):
|
|||
|
||||
import threading
|
||||
t = threading.Thread(target=self._start_http_thread)
|
||||
t.setName('HTTPServer ' + t.getName())
|
||||
t.name = 'HTTPServer ' + t.name
|
||||
t.start()
|
||||
|
||||
self.wait()
|
||||
|
|
|
@ -20,7 +20,7 @@ class ConsoleCtrlHandler(plugins.SimplePlugin):
|
|||
|
||||
def start(self):
|
||||
if self.is_set:
|
||||
self.bus.log('Handler for console events already set.', level=40)
|
||||
self.bus.log('Handler for console events already set.', level=20)
|
||||
return
|
||||
|
||||
result = win32api.SetConsoleCtrlHandler(self.handle, 1)
|
||||
|
@ -28,12 +28,12 @@ class ConsoleCtrlHandler(plugins.SimplePlugin):
|
|||
self.bus.log('Could not SetConsoleCtrlHandler (error %r)' %
|
||||
win32api.GetLastError(), level=40)
|
||||
else:
|
||||
self.bus.log('Set handler for console events.', level=40)
|
||||
self.bus.log('Set handler for console events.', level=20)
|
||||
self.is_set = True
|
||||
|
||||
def stop(self):
|
||||
if not self.is_set:
|
||||
self.bus.log('Handler for console events already off.', level=40)
|
||||
self.bus.log('Handler for console events already off.', level=20)
|
||||
return
|
||||
|
||||
try:
|
||||
|
@ -46,7 +46,7 @@ class ConsoleCtrlHandler(plugins.SimplePlugin):
|
|||
self.bus.log('Could not remove SetConsoleCtrlHandler (error %r)' %
|
||||
win32api.GetLastError(), level=40)
|
||||
else:
|
||||
self.bus.log('Removed handler for console events.', level=40)
|
||||
self.bus.log('Removed handler for console events.', level=20)
|
||||
self.is_set = False
|
||||
|
||||
def handle(self, event):
|
||||
|
|
|
@ -81,7 +81,7 @@ import warnings
|
|||
import subprocess
|
||||
import functools
|
||||
|
||||
import six
|
||||
from more_itertools import always_iterable
|
||||
|
||||
|
||||
# Here I save the value of os.getcwd(), which, if I am imported early enough,
|
||||
|
@ -356,13 +356,13 @@ class Bus(object):
|
|||
# implemented as a windows service and in any other case
|
||||
# that another thread executes cherrypy.engine.exit()
|
||||
if (
|
||||
t != threading.currentThread() and
|
||||
t != threading.current_thread() and
|
||||
not isinstance(t, threading._MainThread) and
|
||||
# Note that any dummy (external) threads are
|
||||
# always daemonic.
|
||||
not t.daemon
|
||||
):
|
||||
self.log('Waiting for thread %s.' % t.getName())
|
||||
self.log('Waiting for thread %s.' % t.name)
|
||||
t.join()
|
||||
|
||||
if self.execv:
|
||||
|
@ -370,10 +370,7 @@ class Bus(object):
|
|||
|
||||
def wait(self, state, interval=0.1, channel=None):
|
||||
"""Poll for the given state(s) at intervals; publish to channel."""
|
||||
if isinstance(state, (tuple, list)):
|
||||
states = state
|
||||
else:
|
||||
states = [state]
|
||||
states = set(always_iterable(state))
|
||||
|
||||
while self.state not in states:
|
||||
time.sleep(interval)
|
||||
|
@ -436,7 +433,7 @@ class Bus(object):
|
|||
:seealso: http://stackoverflow.com/a/28414807/595220
|
||||
"""
|
||||
try:
|
||||
char_p = ctypes.c_char_p if six.PY2 else ctypes.c_wchar_p
|
||||
char_p = ctypes.c_wchar_p
|
||||
|
||||
argv = ctypes.POINTER(char_p)()
|
||||
argc = ctypes.c_int()
|
||||
|
@ -573,7 +570,7 @@ class Bus(object):
|
|||
self.wait(states.STARTED)
|
||||
func(*a, **kw)
|
||||
t = threading.Thread(target=_callback, args=args, kwargs=kwargs)
|
||||
t.setName('Bus Callback ' + t.getName())
|
||||
t.name = 'Bus Callback ' + t.name
|
||||
t.start()
|
||||
|
||||
self.start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue