Module pprocess :: Class Exchange
[show private | hide private]
[frames | no frames]

Class Exchange


A communications exchange that can be used to detect channels which are
ready to communicate. Subclasses of this class can define the 'store_data'
method in order to enable the 'add_wait', 'wait' and 'finish' methods.

Method Summary
  __init__(self, channels, limit, autoclose)
Initialise the exchange with an optional list of 'channels'.
  active(self)
Return a list of active channels.
  add(self, channel)
Add the given 'channel' to the exchange.
  add_wait(self, channel)
Add the given 'channel' to the exchange, waiting if the limit on active channels would be exceeded by adding the channel.
  finish(self)
Finish the use of the exchange by waiting for all channels to complete.
  ready(self, timeout)
Wait for a period of time specified by the optional 'timeout' (or until communication is possible) and return a list of channels which are ready to be read from.
  remove(self, channel)
Remove the given 'channel' from the exchange.
  start(self, callable, *args, **kwargs)
Using pprocess.start, create a new process for the given 'callable' using any additional arguments provided.
  store(self)
For each ready channel, process the incoming data.
  store_data(self, channel)
Store incoming data from the specified 'channel'.
  wait(self)
Test for the limit on channels, blocking and reading incoming data until the number of channels is below the limit.

Method Details

__init__(self, channels=None, limit=None, autoclose=1)
(Constructor)

Initialise the exchange with an optional list of 'channels'.

If the optional 'limit' is specified, restrictions on the addition of
new channels can be enforced and observed through the 'add_wait', 'wait'
and 'finish' methods. To make use of these methods, create a subclass of
this class and define a working 'store_data' method.

If the optional 'autoclose' parameter is set to a false value, channels
will not be closed automatically when they are removed from the exchange
- by default they are closed when removed.

active(self)

Return a list of active channels.

add(self, channel)

Add the given 'channel' to the exchange.

add_wait(self, channel)

Add the given 'channel' to the exchange, waiting if the limit on active
channels would be exceeded by adding the channel.

finish(self)

Finish the use of the exchange by waiting for all channels to complete.

ready(self, timeout=None)

Wait for a period of time specified by the optional 'timeout' (or until
communication is possible) and return a list of channels which are ready
to be read from.

remove(self, channel)

Remove the given 'channel' from the exchange.

start(self, callable, *args, **kwargs)

Using pprocess.start, create a new process for the given 'callable'
using any additional arguments provided. Then, monitor the channel
created between this process and the created process.

store(self)

For each ready channel, process the incoming data.

store_data(self, channel)

Store incoming data from the specified 'channel'. In subclasses of this
class, such data could be stored using instance attributes.

wait(self)

Test for the limit on channels, blocking and reading incoming data until
the number of channels is below the limit.

Generated by Epydoc 2.1 on Sun Jul 8 00:15:26 2007 http://epydoc.sf.net