Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
MoinMoin.support.flup.server.fcgi_fork.WSGIServer Class Reference
Inheritance diagram for MoinMoin.support.flup.server.fcgi_fork.WSGIServer:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.flup.server.fcgi_fork.WSGIServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 capability

Private Member Functions

def _isClientAllowed

Private Attributes

 _web_server_addrs

Detailed Description

FastCGI server that supports the Web Server Gateway Interface. See
http://www.python.org/peps/pep-0333.html.

Definition at line 66 of file fcgi_fork.py.


Constructor & Destructor Documentation

def MoinMoin.support.flup.server.fcgi_fork.WSGIServer.__init__ (   self,
  application,
  environ = None,
  bindAddress = None,
  umask = None,
  multiplexed = False,
  debug = False,
  roles = (FCGI_RESPONDER,,
  forceCGI = False,
  kw 
)
environ, if present, must be a dictionary-like object. Its
contents will be copied into application's environ. Useful
for passing application-specific variables.

bindAddress, if present, must either be a string or a 2-tuple. If
present, run() will open its own listening socket. You would use
this if you wanted to run your application as an 'external' FastCGI
app. (i.e. the webserver would no longer be responsible for starting
your app) If a string, it will be interpreted as a filename and a UNIX
socket will be opened. If a tuple, the first element, a string,
is the interface name/IP to bind to, and the second element (an int)
is the port number.

Definition at line 73 of file fcgi_fork.py.

00073 
00074                  debug=False, roles=(FCGI_RESPONDER,), forceCGI=False, **kw):
00075         """
00076         environ, if present, must be a dictionary-like object. Its
00077         contents will be copied into application's environ. Useful
00078         for passing application-specific variables.
00079 
00080         bindAddress, if present, must either be a string or a 2-tuple. If
00081         present, run() will open its own listening socket. You would use
00082         this if you wanted to run your application as an 'external' FastCGI
00083         app. (i.e. the webserver would no longer be responsible for starting
00084         your app) If a string, it will be interpreted as a filename and a UNIX
00085         socket will be opened. If a tuple, the first element, a string,
00086         is the interface name/IP to bind to, and the second element (an int)
00087         is the port number.
00088         """
00089         BaseFCGIServer.__init__(self, application,
00090                                 environ=environ,
00091                                 multithreaded=False,
00092                                 multiprocess=True,
00093                                 bindAddress=bindAddress,
00094                                 umask=umask,
00095                                 multiplexed=multiplexed,
00096                                 debug=debug,
00097                                 roles=roles,
00098                                 forceCGI=forceCGI)
00099         for key in ('multithreaded', 'multiprocess', 'jobClass', 'jobArgs'):
00100             if kw.has_key(key):
00101                 del kw[key]
00102         PreforkServer.__init__(self, jobClass=self._connectionClass,
00103                                jobArgs=(self,), **kw)
00104 
00105         try:
00106             import resource
00107             # Attempt to glean the maximum number of connections
00108             # from the OS.
00109             try:
00110                 maxProcs = resource.getrlimit(resource.RLIMIT_NPROC)[0]
00111                 maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
00112                 maxConns = min(maxConns, maxProcs)
00113             except AttributeError:
00114                 maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
00115         except ImportError:
00116             maxConns = 100 # Just some made up number.
00117         maxReqs = maxConns
00118         self.capability = {
00119             FCGI_MAX_CONNS: maxConns,
00120             FCGI_MAX_REQS: maxReqs,
00121             FCGI_MPXS_CONNS: 0
00122             }


Member Function Documentation

Definition at line 123 of file fcgi_fork.py.

00123 
00124     def _isClientAllowed(self, addr):
00125         return self._web_server_addrs is None or \
00126                (len(addr) == 2 and addr[0] in self._web_server_addrs)

Here is the caller graph for this function:

The main loop. Exits on SIGHUP, SIGINT, SIGTERM. Returns True if
SIGHUP was received, False otherwise.

Definition at line 127 of file fcgi_fork.py.

00127 
00128     def run(self):
00129         """
00130         The main loop. Exits on SIGHUP, SIGINT, SIGTERM. Returns True if
00131         SIGHUP was received, False otherwise.
00132         """
00133         self._web_server_addrs = os.environ.get('FCGI_WEB_SERVER_ADDRS')
00134         if self._web_server_addrs is not None:
00135             self._web_server_addrs = map(lambda x: x.strip(),
00136                                          self._web_server_addrs.split(','))
00137 
00138         sock = self._setupSocket()
00139 
00140         ret = PreforkServer.run(self, sock)
00141 
00142         self._cleanupSocket(sock)
00143 
00144         return ret


Member Data Documentation

Definition at line 132 of file fcgi_fork.py.

Definition at line 117 of file fcgi_fork.py.


The documentation for this class was generated from the following file: