rox.proxy
index

Given a pair of pipes with a python process at each end, this module
allows one end to make calls on the other. This is used by the su module
to allow control of a subprocess running as another user, but it may also
be useful in other situations.

 
Classes
       
Proxy
MasterProxy
SlaveProxy
Queue
__builtin__.object
MasterObject
Request

 
class MasterObject(__builtin__.object)
      Invoking a method on a MasterObject invokes the corresponding
method on the slave object. The return value is a Queue from
which the responses can be read.
 
  Methods defined here:
__init__(self, master)

 
class MasterProxy(Proxy)
      Invoking operations on MasterProxy.root will invoke the same
operation on the SlaveProxy's slave_object.
 
  Methods defined here:
__init__(self, to_slave, from_slave)
finish(self)

 
class Proxy
       
  Methods defined here:
__init__(self, to_peer, from_peer, slave_object=None)
enable_read_watch(self)
enable_write_watch(self)
finish(self)
lost_connection(self)
read_ready(self)
write_object(self, object)
write_ready(self)
Returns True if the buffer is not empty on exit.

 
class Queue
      A queue of responses to some method call.
Queue.blocker is triggered when the response queue becomes non-empty,
so yield that before trying to read from the queue, if using the
tasks module.
 
For simple use (exactly one response), use:
data = Queue.dequeue_last()
 
For sequences, read the next result with:
data = Queue.dequeue()
Will return EndOfResponses on the last call.
 
  Methods defined here:
__init__(self, master, serial)
add(self, data)
Add an item to the queue and trigger our current blocker.
dequeue(self)
Returns the first item in the queue for this serial number.
Queue.blocker may change to a new blocker (if the queue is now
empty) or None (if no more responses will arrive), so be sure
to reread it after this.
dequeue_last(self)
Calls dequeue, and also sets a flag to indicate that
the next item will be EndOfResponses, which will be handled
automatically.

 
class Request(__builtin__.object)
      Call Request.send() to send replies. When destroyed, sends a
stop message to the master.
 
  Methods defined here:
__init__(self, send)

 
class SlaveProxy(Proxy)
      Methods invoked on MasterProxy.root will be invoked on
slave_object with a callback function as the first argument.
This may be called any number of times to send replies.
 
  Methods defined here:
__init__(self, to_master, from_master, slave_object)
lost_connection(self)

 
Functions
       
select(...)
select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)
 
Wait until one or more file descriptors are ready for some kind of I/O.
The first three arguments are lists of file descriptors to be waited for:
rlist -- wait until ready for reading
wlist -- wait until ready for writing
xlist -- wait for an ``exceptional condition''
If only one kind of condition is required, pass [] for the other lists.
A file descriptor is either a socket or file object, or a small integer
gotten from a fileno() method call on one of those.
 
The optional 4th argument specifies a timeout in seconds; it may be
a floating point number to specify fractions of seconds.  If it is absent
or None, the call will never time out.
 
The return value is a tuple of three lists corresponding to the first three
arguments; each contains the subset of the corresponding file descriptors
that are ready.
 
*** IMPORTANT NOTICE ***
On Windows, only sockets are supported; on Unix, all file descriptors.