mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Remove redundant super() arguments
This commit is contained in:
parent
a2a8bc1ae6
commit
a8963ef1a5
@ -10,7 +10,7 @@ def child_process(queue):
|
|||||||
|
|
||||||
class GunicornSubProcessTestMiddleware(object):
|
class GunicornSubProcessTestMiddleware(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(GunicornSubProcessTestMiddleware, self).__init__()
|
super().__init__()
|
||||||
self.queue = Queue()
|
self.queue = Queue()
|
||||||
self.process = Process(target=child_process, args=(self.queue,))
|
self.process = Process(target=child_process, args=(self.queue,))
|
||||||
self.process.start()
|
self.process.start()
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication):
|
|||||||
def __init__(self, app, options=None):
|
def __init__(self, app, options=None):
|
||||||
self.options = options or {}
|
self.options = options or {}
|
||||||
self.application = app
|
self.application = app
|
||||||
super(StandaloneApplication, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
config = {key: value for key, value in self.options.items()
|
config = {key: value for key, value in self.options.items()
|
||||||
|
|||||||
@ -8,7 +8,7 @@ max_mem = 100000
|
|||||||
class MemoryWatch(threading.Thread):
|
class MemoryWatch(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, server, max_mem):
|
def __init__(self, server, max_mem):
|
||||||
super(MemoryWatch, self).__init__()
|
super().__init__()
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
self.server = server
|
self.server = server
|
||||||
self.max_mem = max_mem
|
self.max_mem = max_mem
|
||||||
|
|||||||
@ -218,4 +218,4 @@ class Application(BaseApplication):
|
|||||||
if pythonpath not in sys.path:
|
if pythonpath not in sys.path:
|
||||||
sys.path.insert(0, pythonpath)
|
sys.path.insert(0, pythonpath)
|
||||||
|
|
||||||
super(Application, self).run()
|
super().run()
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class Config(object):
|
|||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
if name != "settings" and name in self.settings:
|
if name != "settings" and name in self.settings:
|
||||||
raise AttributeError("Invalid access!")
|
raise AttributeError("Invalid access!")
|
||||||
super(Config, self).__setattr__(name, value)
|
super().__setattr__(name, value)
|
||||||
|
|
||||||
def set(self, name, value):
|
def set(self, name, value):
|
||||||
if name not in self.settings:
|
if name not in self.settings:
|
||||||
@ -224,7 +224,7 @@ class Config(object):
|
|||||||
|
|
||||||
class SettingMeta(type):
|
class SettingMeta(type):
|
||||||
def __new__(cls, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
super_new = super(SettingMeta, cls).__new__
|
super_new = super().__new__
|
||||||
parents = [b for b in bases if isinstance(b, SettingMeta)]
|
parents = [b for b in bases if isinstance(b, SettingMeta)]
|
||||||
if not parents:
|
if not parents:
|
||||||
return super_new(cls, name, bases, attrs)
|
return super_new(cls, name, bases, attrs)
|
||||||
|
|||||||
@ -108,11 +108,11 @@ class SafeAtoms(dict):
|
|||||||
if k.startswith("{"):
|
if k.startswith("{"):
|
||||||
kl = k.lower()
|
kl = k.lower()
|
||||||
if kl in self:
|
if kl in self:
|
||||||
return super(SafeAtoms, self).__getitem__(kl)
|
return super().__getitem__(kl)
|
||||||
else:
|
else:
|
||||||
return "-"
|
return "-"
|
||||||
if k in self:
|
if k in self:
|
||||||
return super(SafeAtoms, self).__getitem__(k)
|
return super().__getitem__(k)
|
||||||
else:
|
else:
|
||||||
return '-'
|
return '-'
|
||||||
|
|
||||||
|
|||||||
@ -177,7 +177,7 @@ class Request(Message):
|
|||||||
|
|
||||||
self.req_number = req_number
|
self.req_number = req_number
|
||||||
self.proxy_protocol_info = None
|
self.proxy_protocol_info = None
|
||||||
super(Request, self).__init__(cfg, unreader)
|
super().__init__(cfg, unreader)
|
||||||
|
|
||||||
def get_data(self, unreader, buf, stop=False):
|
def get_data(self, unreader, buf, stop=False):
|
||||||
data = unreader.read()
|
data = unreader.read()
|
||||||
@ -357,6 +357,6 @@ class Request(Message):
|
|||||||
self.version = (int(match.group(1)), int(match.group(2)))
|
self.version = (int(match.group(1)), int(match.group(2)))
|
||||||
|
|
||||||
def set_body_reader(self):
|
def set_body_reader(self):
|
||||||
super(Request, self).set_body_reader()
|
super().set_body_reader()
|
||||||
if isinstance(self.body.reader, EOFReader):
|
if isinstance(self.body.reader, EOFReader):
|
||||||
self.body = Body(LengthReader(self.unreader, 0))
|
self.body = Body(LengthReader(self.unreader, 0))
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class Unreader(object):
|
|||||||
|
|
||||||
class SocketUnreader(Unreader):
|
class SocketUnreader(Unreader):
|
||||||
def __init__(self, sock, max_chunk=8192):
|
def __init__(self, sock, max_chunk=8192):
|
||||||
super(SocketUnreader, self).__init__()
|
super().__init__()
|
||||||
self.sock = sock
|
self.sock = sock
|
||||||
self.mxchunk = max_chunk
|
self.mxchunk = max_chunk
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class SocketUnreader(Unreader):
|
|||||||
|
|
||||||
class IterUnreader(Unreader):
|
class IterUnreader(Unreader):
|
||||||
def __init__(self, iterable):
|
def __init__(self, iterable):
|
||||||
super(IterUnreader, self).__init__()
|
super().__init__()
|
||||||
self.iter = iter(iterable)
|
self.iter = iter(iterable)
|
||||||
|
|
||||||
def chunk(self):
|
def chunk(self):
|
||||||
|
|||||||
@ -15,7 +15,7 @@ COMPILED_EXT_RE = re.compile(r'py[co]$')
|
|||||||
|
|
||||||
class Reloader(threading.Thread):
|
class Reloader(threading.Thread):
|
||||||
def __init__(self, extra_files=None, interval=1, callback=None):
|
def __init__(self, extra_files=None, interval=1, callback=None):
|
||||||
super(Reloader, self).__init__()
|
super().__init__()
|
||||||
self.setDaemon(True)
|
self.setDaemon(True)
|
||||||
self._extra_files = set(extra_files or ())
|
self._extra_files = set(extra_files or ())
|
||||||
self._extra_files_lock = threading.RLock()
|
self._extra_files_lock = threading.RLock()
|
||||||
@ -74,7 +74,7 @@ if has_inotify:
|
|||||||
| inotify.constants.IN_MOVED_TO)
|
| inotify.constants.IN_MOVED_TO)
|
||||||
|
|
||||||
def __init__(self, extra_files=None, callback=None):
|
def __init__(self, extra_files=None, callback=None):
|
||||||
super(InotifyReloader, self).__init__()
|
super().__init__()
|
||||||
self.setDaemon(True)
|
self.setDaemon(True)
|
||||||
self._callback = callback
|
self._callback = callback
|
||||||
self._dirs = set()
|
self._dirs = set()
|
||||||
|
|||||||
@ -87,7 +87,7 @@ class TCPSocket(BaseSocket):
|
|||||||
|
|
||||||
def set_options(self, sock, bound=False):
|
def set_options(self, sock, bound=False):
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
return super(TCPSocket, self).set_options(sock, bound=bound)
|
return super().set_options(sock, bound=bound)
|
||||||
|
|
||||||
|
|
||||||
class TCP6Socket(TCPSocket):
|
class TCP6Socket(TCPSocket):
|
||||||
@ -115,7 +115,7 @@ class UnixSocket(BaseSocket):
|
|||||||
os.remove(addr)
|
os.remove(addr)
|
||||||
else:
|
else:
|
||||||
raise ValueError("%r is not a socket" % addr)
|
raise ValueError("%r is not a socket" % addr)
|
||||||
super(UnixSocket, self).__init__(addr, conf, log, fd=fd)
|
super().__init__(addr, conf, log, fd=fd)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "unix:%s" % self.cfg_addr
|
return "unix:%s" % self.cfg_addr
|
||||||
|
|||||||
@ -85,8 +85,7 @@ class Worker(object):
|
|||||||
"""\
|
"""\
|
||||||
If you override this method in a subclass, the last statement
|
If you override this method in a subclass, the last statement
|
||||||
in the function should be to call this method with
|
in the function should be to call this method with
|
||||||
super(MyWorkerClass, self).init_process() so that the ``run()``
|
super().init_process() so that the ``run()`` loop is initiated.
|
||||||
loop is initiated.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# set environment' variables
|
# set environment' variables
|
||||||
|
|||||||
@ -20,7 +20,7 @@ ALREADY_HANDLED = object()
|
|||||||
class AsyncWorker(base.Worker):
|
class AsyncWorker(base.Worker):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AsyncWorker, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.worker_connections = self.cfg.worker_connections
|
self.worker_connections = self.cfg.worker_connections
|
||||||
|
|
||||||
def timeout_ctx(self):
|
def timeout_ctx(self):
|
||||||
|
|||||||
@ -93,17 +93,17 @@ class EventletWorker(AsyncWorker):
|
|||||||
if respiter == EVENTLET_ALREADY_HANDLED:
|
if respiter == EVENTLET_ALREADY_HANDLED:
|
||||||
raise StopIteration()
|
raise StopIteration()
|
||||||
else:
|
else:
|
||||||
return super(EventletWorker, self).is_already_handled(respiter)
|
return super().is_already_handled(respiter)
|
||||||
|
|
||||||
def init_process(self):
|
def init_process(self):
|
||||||
super(EventletWorker, self).init_process()
|
super().init_process()
|
||||||
self.patch()
|
self.patch()
|
||||||
|
|
||||||
def handle_quit(self, sig, frame):
|
def handle_quit(self, sig, frame):
|
||||||
eventlet.spawn(super(EventletWorker, self).handle_quit, sig, frame)
|
eventlet.spawn(super().handle_quit, sig, frame)
|
||||||
|
|
||||||
def handle_usr1(self, sig, frame):
|
def handle_usr1(self, sig, frame):
|
||||||
eventlet.spawn(super(EventletWorker, self).handle_usr1, sig, frame)
|
eventlet.spawn(super().handle_usr1, sig, frame)
|
||||||
|
|
||||||
def timeout_ctx(self):
|
def timeout_ctx(self):
|
||||||
return eventlet.Timeout(self.cfg.keepalive or None, False)
|
return eventlet.Timeout(self.cfg.keepalive or None, False)
|
||||||
@ -113,7 +113,7 @@ class EventletWorker(AsyncWorker):
|
|||||||
client = eventlet.wrap_ssl(client, server_side=True,
|
client = eventlet.wrap_ssl(client, server_side=True,
|
||||||
**self.cfg.ssl_options)
|
**self.cfg.ssl_options)
|
||||||
|
|
||||||
super(EventletWorker, self).handle(listener, client, addr)
|
super().handle(listener, client, addr)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
acceptors = []
|
acceptors = []
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class GeventWorker(AsyncWorker):
|
|||||||
self.sockets = sockets
|
self.sockets = sockets
|
||||||
|
|
||||||
def notify(self):
|
def notify(self):
|
||||||
super(GeventWorker, self).notify()
|
super().notify()
|
||||||
if self.ppid != os.getppid():
|
if self.ppid != os.getppid():
|
||||||
self.log.info("Parent changed, shutting down: %s", self)
|
self.log.info("Parent changed, shutting down: %s", self)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -136,12 +136,11 @@ class GeventWorker(AsyncWorker):
|
|||||||
# Connected socket timeout defaults to socket.getdefaulttimeout().
|
# Connected socket timeout defaults to socket.getdefaulttimeout().
|
||||||
# This forces to blocking mode.
|
# This forces to blocking mode.
|
||||||
client.setblocking(1)
|
client.setblocking(1)
|
||||||
super(GeventWorker, self).handle(listener, client, addr)
|
super().handle(listener, client, addr)
|
||||||
|
|
||||||
def handle_request(self, listener_name, req, sock, addr):
|
def handle_request(self, listener_name, req, sock, addr):
|
||||||
try:
|
try:
|
||||||
super(GeventWorker, self).handle_request(listener_name, req, sock,
|
super().handle_request(listener_name, req, sock, addr)
|
||||||
addr)
|
|
||||||
except gevent.GreenletExit:
|
except gevent.GreenletExit:
|
||||||
pass
|
pass
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
@ -150,17 +149,17 @@ class GeventWorker(AsyncWorker):
|
|||||||
def handle_quit(self, sig, frame):
|
def handle_quit(self, sig, frame):
|
||||||
# Move this out of the signal handler so we can use
|
# Move this out of the signal handler so we can use
|
||||||
# blocking calls. See #1126
|
# blocking calls. See #1126
|
||||||
gevent.spawn(super(GeventWorker, self).handle_quit, sig, frame)
|
gevent.spawn(super().handle_quit, sig, frame)
|
||||||
|
|
||||||
def handle_usr1(self, sig, frame):
|
def handle_usr1(self, sig, frame):
|
||||||
# Make the gevent workers handle the usr1 signal
|
# Make the gevent workers handle the usr1 signal
|
||||||
# by deferring to a new greenlet. See #1645
|
# by deferring to a new greenlet. See #1645
|
||||||
gevent.spawn(super(GeventWorker, self).handle_usr1, sig, frame)
|
gevent.spawn(super().handle_usr1, sig, frame)
|
||||||
|
|
||||||
def init_process(self):
|
def init_process(self):
|
||||||
self.patch()
|
self.patch()
|
||||||
hub.reinit()
|
hub.reinit()
|
||||||
super(GeventWorker, self).init_process()
|
super().init_process()
|
||||||
|
|
||||||
|
|
||||||
class GeventResponse(object):
|
class GeventResponse(object):
|
||||||
@ -190,7 +189,7 @@ class PyWSGIHandler(pywsgi.WSGIHandler):
|
|||||||
self.server.log.access(resp, req_headers, self.environ, response_time)
|
self.server.log.access(resp, req_headers, self.environ, response_time)
|
||||||
|
|
||||||
def get_environ(self):
|
def get_environ(self):
|
||||||
env = super(PyWSGIHandler, self).get_environ()
|
env = super().get_environ()
|
||||||
env['gunicorn.sock'] = self.socket
|
env['gunicorn.sock'] = self.socket
|
||||||
env['RAW_URI'] = self.path
|
env['RAW_URI'] = self.path
|
||||||
return env
|
return env
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class TConn(object):
|
|||||||
class ThreadWorker(base.Worker):
|
class ThreadWorker(base.Worker):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ThreadWorker, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.worker_connections = self.cfg.worker_connections
|
self.worker_connections = self.cfg.worker_connections
|
||||||
self.max_keepalived = self.cfg.worker_connections - self.cfg.threads
|
self.max_keepalived = self.cfg.worker_connections - self.cfg.threads
|
||||||
# initialise the pool
|
# initialise the pool
|
||||||
@ -88,7 +88,7 @@ class ThreadWorker(base.Worker):
|
|||||||
self.tpool = self.get_thread_pool()
|
self.tpool = self.get_thread_pool()
|
||||||
self.poller = selectors.DefaultSelector()
|
self.poller = selectors.DefaultSelector()
|
||||||
self._lock = RLock()
|
self._lock = RLock()
|
||||||
super(ThreadWorker, self).init_process()
|
super().init_process()
|
||||||
|
|
||||||
def get_thread_pool(self):
|
def get_thread_pool(self):
|
||||||
"""Override this method to customize how the thread pool is created"""
|
"""Override this method to customize how the thread pool is created"""
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class TornadoWorker(Worker):
|
|||||||
|
|
||||||
def handle_exit(self, sig, frame):
|
def handle_exit(self, sig, frame):
|
||||||
if self.alive:
|
if self.alive:
|
||||||
super(TornadoWorker, self).handle_exit(sig, frame)
|
super().handle_exit(sig, frame)
|
||||||
|
|
||||||
def handle_request(self):
|
def handle_request(self):
|
||||||
self.nr += 1
|
self.nr += 1
|
||||||
@ -84,7 +84,7 @@ class TornadoWorker(Worker):
|
|||||||
# should create its own IOLoop. We should clear current IOLoop
|
# should create its own IOLoop. We should clear current IOLoop
|
||||||
# if exists before os.fork.
|
# if exists before os.fork.
|
||||||
IOLoop.clear_current()
|
IOLoop.clear_current()
|
||||||
super(TornadoWorker, self).init_process()
|
super().init_process()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.ioloop = IOLoop.instance()
|
self.ioloop = IOLoop.instance()
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class PreloadedAppWithEnvSettings(DummyApplication):
|
|||||||
'preloaded' application.
|
'preloaded' application.
|
||||||
"""
|
"""
|
||||||
verify_env_vars()
|
verify_env_vars()
|
||||||
return super(PreloadedAppWithEnvSettings, self).wsgi()
|
return super().wsgi()
|
||||||
|
|
||||||
|
|
||||||
def verify_env_vars():
|
def verify_env_vars():
|
||||||
|
|||||||
@ -42,7 +42,7 @@ class AltArgs(object):
|
|||||||
|
|
||||||
class NoConfigApp(Application):
|
class NoConfigApp(Application):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NoConfigApp, self).__init__("no_usage", prog="gunicorn_test")
|
super().__init__("no_usage", prog="gunicorn_test")
|
||||||
|
|
||||||
def init(self, parser, opts, args):
|
def init(self, parser, opts, args):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user