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

Public Member Functions

def __init__
 
def clear
 
def insort_event_right
 
def queue_call
 
def queue_rpc
 
def add_idle
 
def run_idle
 
def run0
 
def run1
 
def run
 

Public Attributes

 current
 
 idlers
 
 inactive
 
 queue
 
 rpcs
 

Detailed Description

An event loop.

Constructor & Destructor Documentation

def google.appengine.ext.ndb.eventloop.EventLoop.__init__ (   self)
Constructor.

Fields:
  current: a FIFO list of (callback, args, kwds). These callbacks
run immediately when the eventloop runs.
  idlers: a FIFO list of (callback, args, kwds). Thes callbacks
run only when no other RPCs need to be fired first.
For example, AutoBatcher uses idler to fire a batch RPC even before
the batch is full.
  queue: a sorted list of (absolute time in sec, callback, args, kwds),
sorted by time. These callbacks run only after the said time.
  rpcs: a map from rpc to (callback, args, kwds). Callback is called
when the rpc finishes.

Member Function Documentation

def google.appengine.ext.ndb.eventloop.EventLoop.add_idle (   self,
  callback,
  args,
  kwds 
)
Add an idle callback.

An idle callback can return True, False or None.  These mean:

- None: remove the callback (don't reschedule)
- False: the callback did no work; reschedule later
- True: the callback did some work; reschedule soon

If the callback raises an exception, the traceback is logged and
the callback is removed.
def google.appengine.ext.ndb.eventloop.EventLoop.clear (   self)
Remove all pending events without running any.
def google.appengine.ext.ndb.eventloop.EventLoop.insort_event_right (   self,
  event,
  lo = 0,
  hi = None 
)
Insert event in queue, and keep it sorted assuming queue is sorted.

If event is already in queue, insert it to the right of the rightmost
event (to keep FIFO order).

Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.

Args:
  event: a (time in sec since unix epoch, callback, args, kwds) tuple.
def google.appengine.ext.ndb.eventloop.EventLoop.queue_call (   self,
  delay,
  callback,
  args,
  kwds 
)
Schedule a function call at a specific time in the future.
def google.appengine.ext.ndb.eventloop.EventLoop.queue_rpc (   self,
  rpc,
  callback = None,
  args,
  kwds 
)
Schedule an RPC with an optional callback.

The caller must have previously sent the call to the service.
The optional callback is called with the remaining arguments.

NOTE: If the rpc is a MultiRpc, the callback will be called once
for each sub-RPC.  TODO: Is this a good idea?
def google.appengine.ext.ndb.eventloop.EventLoop.run (   self)
Run until there's nothing left to do.
def google.appengine.ext.ndb.eventloop.EventLoop.run0 (   self)
Run one item (a callback or an RPC wait_any).

Returns:
  A time to sleep if something happened (may be 0);
  None if all queues are empty.
def google.appengine.ext.ndb.eventloop.EventLoop.run1 (   self)
Run one item (a callback or an RPC wait_any) or sleep.

Returns:
  True if something happened; False if all queues are empty.
def google.appengine.ext.ndb.eventloop.EventLoop.run_idle (   self)
Run one of the idle callbacks.

Returns:
  True if one was called, False if no idle callback was called.

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