summaryrefslogtreecommitdiff
path: root/wsgitools/scgi
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/scgi')
-rw-r--r--wsgitools/scgi/__init__.py4
-rw-r--r--wsgitools/scgi/asynchronous.py9
-rw-r--r--wsgitools/scgi/forkpool.py22
3 files changed, 7 insertions, 28 deletions
diff --git a/wsgitools/scgi/__init__.py b/wsgitools/scgi/__init__.py
index f651264..e2a68c2 100644
--- a/wsgitools/scgi/__init__.py
+++ b/wsgitools/scgi/__init__.py
@@ -7,7 +7,7 @@ except ImportError:
else:
have_sendfile = True
-class FileWrapper(object):
+class FileWrapper:
"""
@ivar offset: Initially 0. Becomes -1 when reading using next and
becomes positive when reading using next. In the latter case it
@@ -52,8 +52,6 @@ class FileWrapper(object):
if data:
return data
raise StopIteration
- def next(self):
- return self.__next__()
def _convert_environ(environ, multithread=False, multiprocess=False,
run_once=False):
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py
index 0b014bf..61bbc6b 100644
--- a/wsgitools/scgi/asynchronous.py
+++ b/wsgitools/scgi/asynchronous.py
@@ -9,13 +9,6 @@ import errno
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]
-
class SCGIConnection(asyncore.dispatcher):
"""SCGI connection class used by L{SCGIServer}."""
# connection states
@@ -147,7 +140,7 @@ class SCGIConnection(asyncore.dispatcher):
if exc_info:
if self.outheaders == True:
try:
- raise exc_info_for_raise(exc_info)
+ raise exc_info[1].with_traceback(exc_info[2])
finally:
exc_info = None
assert self.outheaders != True # unsent
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)