summaryrefslogtreecommitdiff
path: root/wsgitools/scgi/forkpool.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-06-17 19:35:21 +0200
committerHelmut Grohne <helmut@subdivi.de>2023-06-18 22:44:01 +0200
commit4d52eaa4801df3f3169df8e58758bcccf22dc4de (patch)
treeb8740a88e380a750d9d2607bb39cbc759a8d7175 /wsgitools/scgi/forkpool.py
parent682ce67b73453809237532a7ce2feee07f2900d5 (diff)
downloadwsgitools-4d52eaa4801df3f3169df8e58758bcccf22dc4de.tar.gz
drop support for Python 2.x
Diffstat (limited to 'wsgitools/scgi/forkpool.py')
-rw-r--r--wsgitools/scgi/forkpool.py22
1 files changed, 5 insertions, 17 deletions
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)