From 4d52eaa4801df3f3169df8e58758bcccf22dc4de Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 17 Jun 2023 19:35:21 +0200 Subject: drop support for Python 2.x --- wsgitools/scgi/forkpool.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'wsgitools/scgi/forkpool.py') diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index 752f0e7..df8a92f 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -5,10 +5,7 @@ It works with multiple processes that are periodically cleaned up to prevent memory leaks having an impact to the system. """ -try: - import resource -except ImportError: - resource = None +import resource import socket import os import select @@ -19,16 +16,9 @@ import signal from wsgitools.internal import bytes2str, str2bytes from wsgitools.scgi import _convert_environ, FileWrapper -if sys.version_info[0] >= 3: - def exc_info_for_raise(exc_info): - return exc_info[1].with_traceback(exc_info[2]) -else: - def exc_info_for_raise(exc_info): - return exc_info[0], exc_info[1], exc_info[2] - __all__ = [] -class SocketFileWrapper(object): +class SocketFileWrapper: """Wraps a socket to a wsgi-compliant file-like object.""" def __init__(self, sock, toread): """@param sock: is a C{socket.socket()}""" @@ -149,8 +139,6 @@ class SocketFileWrapper(object): if not data: raise StopIteration return data - def next(self): - return self.__next__() def flush(self): """see pep333""" def write(self, data): @@ -167,10 +155,10 @@ class SocketFileWrapper(object): self.write(line) __all__.append("SCGIServer") -class SCGIServer(object): +class SCGIServer: """Usage: create an L{SCGIServer} object and invoke the run method which will then turn this process into an scgi server.""" - class WorkerState(object): + class WorkerState: """state: 0 means idle and 1 means working. These values are also sent as strings '0' and '1' over the socket.""" def __init__(self, pid, sock, state): @@ -472,7 +460,7 @@ class SCGIServer(object): def start_response(status, headers, exc_info=None): if exc_info and response_head[0]: try: - raise exc_info_for_raise(exc_info) + raise exc_info[1].with_traceback(exc_info[2]) finally: exc_info = None assert isinstance(status, str) -- cgit v1.2.3