# HG changeset patch # User paulb # Date 1189819272 0 # Node ID 0975a26e47a00abbb6690d90ab78c0a0b0189015 # Parent df9f7a4e712b47e5dfdf09add8391c8a0b05f055 [project @ 2007-09-15 01:21:12 by paulb] Added a queue of requests for callable invocations. Updated release information. diff -r df9f7a4e712b -r 0975a26e47a0 pprocess.py --- a/pprocess.py Sat Sep 15 00:12:05 2007 +0000 +++ b/pprocess.py Sat Sep 15 01:21:12 2007 +0000 @@ -251,7 +251,7 @@ http://www.greenend.org.uk/rjk/2001/06/poll.html """ -__version__ = "0.2.6" +__version__ = "0.3" import os import sys @@ -383,6 +383,7 @@ """ self.limit = limit + self.waiting = [] self.autoclose = autoclose self.readables = {} self.removed = [] @@ -470,6 +471,16 @@ while self.limit is not None and len(self.active()) >= self.limit: self.store() + def start_waiting(self): + + """ + Start a waiting process. + """ + + if self.waiting: + callable, args, kw = self.waiting.pop() + self.add(start(callable, *args, **kw)) + def finish(self): """ @@ -485,6 +496,7 @@ for channel in self.ready(): self.store_data(channel) + self.start_waiting() def store_data(self, channel): @@ -505,6 +517,10 @@ created between this process and the created process. """ + if self.limit is not None and len(self.active()) >= self.limit: + self.waiting.insert(0, (callable, args, kw)) + return + self.add_wait(start(callable, *args, **kw)) def create(self): @@ -709,7 +725,7 @@ exc_type, exc_value, exc_traceback = sys.exc_info() channel.send(exc_value) finally: - pprocess.exit(channel) + exit(channel) else: return channel