Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes
MoinMoin.util.rpc_aggregator.RPCYielder Class Reference

List of all members.

Public Member Functions

def __init__
def fetch_call
def set_result
def fetch_result
def run

Public Attributes

 raise_fault

Private Attributes

 _comm_slot
 _gen

Detailed Description

If you want to have a batchable function, you need
to inherit from this class and define a method "run" that
takes exactly one argument.
This method has to be a generator that yields (func, arg)
tuples whereas func is the RPC method name (str).
You can fetch the calls by calling fetch_call(),
then you have to return the result by calling set_result(res).

Definition at line 15 of file rpc_aggregator.py.


Constructor & Destructor Documentation

def MoinMoin.util.rpc_aggregator.RPCYielder.__init__ (   self,
  arg,
  raise_fault = False 
)

Definition at line 25 of file rpc_aggregator.py.

00025 
00026     def __init__(self, arg, raise_fault=False):
00027         self._comm_slot = [INVALID]
00028         self.raise_fault = raise_fault
00029         self._gen = self.run(arg)


Member Function Documentation

Definition at line 30 of file rpc_aggregator.py.

00030 
00031     def fetch_call(self):
00032         try:
00033             next_item = self._gen.next()
00034         except StopIteration:
00035             return None
00036         return next_item

Definition at line 40 of file rpc_aggregator.py.

00040 
00041     def fetch_result(self):
00042         result = self._comm_slot[0]
00043         try:
00044             if result is INVALID:
00045                 return RuntimeError("Invalid state, there is no result to fetch.")
00046             if self.raise_fault and isinstance(result, xmlrpclib.Fault):
00047                 raise result
00048             else:
00049                 return result
00050         finally:
00051             self._comm_slot[0] = INVALID

Definition at line 52 of file rpc_aggregator.py.

00052 
00053     def run(self, arg):
00054         return NotImplementedError
00055 

Definition at line 37 of file rpc_aggregator.py.

00037 
00038     def set_result(self, result):
00039         self._comm_slot[0] = result


Member Data Documentation

Definition at line 26 of file rpc_aggregator.py.

Definition at line 28 of file rpc_aggregator.py.

Definition at line 27 of file rpc_aggregator.py.


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