Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
ForkingMixIn Class Reference
Inheritance diagram for ForkingMixIn:
ForkingTCPServer ForkingUDPServer

Public Member Functions

def collect_children
 
def process_request
 

Static Public Attributes

 active_children = None
 
int max_children = 40
 

Detailed Description

Mix-in class to handle each request in a new process.

Definition at line 401 of file SocketServer.py.

Member Function Documentation

def collect_children (   self)
Internal routine to wait for died children.

Definition at line 408 of file SocketServer.py.

References ForkingMixIn.active_children, and ForkingMixIn.max_children.

409  def collect_children(self):
410  """Internal routine to wait for died children."""
411  while self.active_children:
412  if len(self.active_children) < self.max_children:
413  options = os.WNOHANG
414  else:
415  # If the maximum number of children are already
416  # running, block while waiting for a child to exit
417  options = 0
418  try:
419  pid, status = os.waitpid(0, options)
420  except os.error:
421  pid = None
422  if not pid: break
423  self.active_children.remove(pid)
def process_request (   self,
  request,
  client_address 
)
Fork a new subprocess to process the request.

Definition at line 424 of file SocketServer.py.

References ForkingMixIn.active_children, BaseServer.close_request(), TCPServer.close_request(), UDPServer.close_request(), ForkingMixIn.collect_children(), BaseServer.finish_request(), OpenerDirector.handle_error, and BaseServer.handle_error().

425  def process_request(self, request, client_address):
426  """Fork a new subprocess to process the request."""
427  self.collect_children()
428  pid = os.fork()
429  if pid:
430  # Parent process
431  if self.active_children is None:
432  self.active_children = []
433  self.active_children.append(pid)
434  self.close_request(request)
435  return
436  else:
437  # Child process.
438  # This must never return, hence os._exit()!
439  try:
440  self.finish_request(request, client_address)
441  os._exit(0)
442  except:
443  try:
444  self.handle_error(request, client_address)
445  finally:
446  os._exit(1)
447 

Field Documentation

active_children = None
static

Definition at line 405 of file SocketServer.py.

int max_children = 40
static

Definition at line 406 of file SocketServer.py.


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