App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | List of all members
google.appengine.datastore.datastore_rpc.MultiRpc Class Reference
Inheritance diagram for google.appengine.datastore.datastore_rpc.MultiRpc:

Public Member Functions

def __init__
 
def rpcs
 
def state
 
def wait
 
def check_success
 
def get_result
 
def flatten
 
def wait_any
 
def wait_all
 

Detailed Description

A wrapper around multiple UserRPC objects.

This provides an API similar to that of UserRPC, but wraps multiple
RPCs such that e.g. .wait() blocks until all wrapped RPCs are
complete, and .get_result() returns the combined results from all
wrapped RPCs.

Class methods:
  flatten(rpcs): Expand a list of UserRPCs and MultiRpcs
    into a list of UserRPCs.
  wait_any(rpcs): Call UserRPC.wait_any(flatten(rpcs)).
  wait_all(rpcs): Call UserRPC.wait_all(flatten(rpcs)).

Instance methods:
  wait(): Wait for all RPCs.
  check_success(): Wait and then check success for all RPCs.
  get_result(): Wait for all, check successes, then merge
    all results.

Instance attributes:
  rpcs: The list of wrapped RPCs (returns a copy).
  state: The combined state of all RPCs.

Constructor & Destructor Documentation

def google.appengine.datastore.datastore_rpc.MultiRpc.__init__ (   self,
  rpcs,
  extra_hook = None 
)
Constructor.

Args:
  rpcs: A list of UserRPC and MultiRpc objects; it is flattened
before being stored.
  extra_hook: Optional function to be applied to the final result
or list of results.

Member Function Documentation

def google.appengine.datastore.datastore_rpc.MultiRpc.check_success (   self)
Check success of all wrapped RPCs, failing if any of the failed.

This mimics the UserRPC.check_success() method.

NOTE: This first waits for all wrapped RPCs to finish before
checking the success of any of them.  This makes debugging easier.
def google.appengine.datastore.datastore_rpc.MultiRpc.flatten (   cls,
  rpcs 
)
Return a list of UserRPCs, expanding MultiRpcs in the argument list.

For example: given 4 UserRPCs rpc1 through rpc4,
flatten(rpc1, MultiRpc([rpc2, rpc3], rpc4)
returns [rpc1, rpc2, rpc3, rpc4].

Args:
  rpcs: A list of UserRPC and MultiRpc objects.

Returns:
  A list of UserRPC objects.
def google.appengine.datastore.datastore_rpc.MultiRpc.get_result (   self)
Return the combined results of all wrapped RPCs.

This mimics the UserRPC.get_results() method.  Multiple results
are combined using the following rules:

1. If there are no wrapped RPCs, an empty list is returned.

2. If exactly one RPC is wrapped, its result is returned.

3. If more than one RPC is wrapped, the result is always a list,
   which is constructed from the wrapped results as follows:

   a. A wrapped result equal to None is ignored;

   b. A wrapped result that is a list (but not any other type of
  sequence!) has its elements added to the result list.

   c. Any other wrapped result is appended to the result list.

After all results are combined, if __extra_hook is set, it is
called with the combined results and its return value becomes the
final result.

NOTE: This first waits for all wrapped RPCs to finish, and then
checks all their success.  This makes debugging easier.
def google.appengine.datastore.datastore_rpc.MultiRpc.rpcs (   self)
Get a flattened list containing the RPCs wrapped.

This returns a copy to prevent users from modifying the state.
def google.appengine.datastore.datastore_rpc.MultiRpc.state (   self)
Get the combined state of the wrapped RPCs.

This mimics the UserRPC.state property.  If all wrapped RPCs have
the same state, that state is returned; otherwise, RUNNING is
returned (which here really means 'neither fish nor flesh').
def google.appengine.datastore.datastore_rpc.MultiRpc.wait (   self)
Wait for all wrapped RPCs to finish.

This mimics the UserRPC.wait() method.
def google.appengine.datastore.datastore_rpc.MultiRpc.wait_all (   cls,
  rpcs 
)
Wait until all RPCs passed in are finished.

This mimics UserRPC.wait_all().

Args:
  rpcs: A list of UserRPC and MultiRpc objects.
def google.appengine.datastore.datastore_rpc.MultiRpc.wait_any (   cls,
  rpcs 
)
Wait until one of the RPCs passed in is finished.

This mimics UserRPC.wait_any().

Args:
  rpcs: A list of UserRPC and MultiRpc objects.

Returns:
  A UserRPC object or None.

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