1.1 --- a/pprocess.py Thu May 21 19:24:06 2009 +0200
1.2 +++ b/pprocess.py Thu Jun 04 22:28:43 2009 +0200
1.3 @@ -238,7 +238,7 @@
1.4 method in order to enable the 'add_wait', 'wait' and 'finish' methods.
1.5 """
1.6
1.7 - def __init__(self, channels=None, limit=None, reuse=0, autoclose=1):
1.8 + def __init__(self, channels=None, limit=None, reuse=0, continuous=0, autoclose=1):
1.9
1.10 """
1.11 Initialise the exchange with an optional list of 'channels'.
1.12 @@ -249,7 +249,13 @@
1.13 this class and define a working 'store_data' method.
1.14
1.15 If the optional 'reuse' parameter is set to a true value, channels and
1.16 - processes will be reused for waiting computations.
1.17 + processes will be reused for waiting computations, but the callable will
1.18 + be invoked for each computation.
1.19 +
1.20 + If the optional 'continuous' parameter is set to a true value, channels
1.21 + and processes will be retained after receiving data sent from such
1.22 + processes, since it will be assumed that they will communicate more
1.23 + data.
1.24
1.25 If the optional 'autoclose' parameter is set to a false value, channels
1.26 will not be closed automatically when they are removed from the exchange
1.27 @@ -259,10 +265,13 @@
1.28 self.limit = limit
1.29 self.reuse = reuse
1.30 self.autoclose = autoclose
1.31 + self.continuous = continuous
1.32 +
1.33 self.waiting = []
1.34 self.readables = {}
1.35 self.removed = []
1.36 self.poller = select.poll()
1.37 +
1.38 for channel in channels or []:
1.39 self.add(channel)
1.40
1.41 @@ -367,6 +376,13 @@
1.42
1.43 self.add(channel)
1.44 channel.send((args, kw))
1.45 +
1.46 + # For continuous channels, no action is taken on the channel or on
1.47 + # new callable information.
1.48 +
1.49 + elif self.continuous:
1.50 + return None
1.51 +
1.52 else:
1.53 return callable, args, kw
1.54