flup.server.preforkserver
¶
-
class
flup.server.preforkserver.
PreforkServer
(minSpare=1, maxSpare=5, maxChildren=50, maxRequests=0, sockTimeout=0, jobClass=None, jobArgs=())¶ A preforked server model conceptually similar to Apache httpd(2). At any given time, ensures there are at least minSpare children ready to process new requests (up to a maximum of maxChildren children total). If the number of idle children is ever above maxSpare, the extra children are killed.
If maxRequests is positive, each child will only handle that many requests in its lifetime before exiting.
jobClass should be a class whose constructor takes at least two arguments: the client socket and client address. jobArgs, which must be a list or tuple, is any additional (static) arguments you wish to pass to the constructor.
jobClass should have a run() method (taking no arguments) that does the actual work. When run() returns, the request is considered complete and the child process moves to idle state.
– added by Velko Ivanov sockTimeout is a timeout in seconds for the server’s sockets. This should be 0 (pure non-blocking mode, default) or more (timeout mode). Fractional values (float) accepted. Setting this could help limit the damage in situations of bad connectivity.
-
run
(sock)¶ The main loop. Pass a socket that is ready to accept() client connections. Return value will be True or False indiciating whether or not the loop was exited due to SIGHUP.
-
-
flup.server.preforkserver.
setCloseOnExec
(sock)¶