proc.RunningProcSet: add __iter__ and allow initialization from constructor
This commit is contained in:
@@ -662,8 +662,14 @@ class RunningProcSet(object):
|
|||||||
"""Maintain a set of Procs that are still running, that is, automatically remove
|
"""Maintain a set of Procs that are still running, that is, automatically remove
|
||||||
a proc when it's finished. Provide a way to wait/kill all of them"""
|
a proc when it's finished. Provide a way to wait/kill all of them"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, *args):
|
||||||
self.procs = set()
|
self.procs = set(*args)
|
||||||
|
if args:
|
||||||
|
for p in self.args[0]:
|
||||||
|
p.link(lambda p: self.procs.discard(p))
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.procs)
|
||||||
|
|
||||||
def add(self, p):
|
def add(self, p):
|
||||||
self.procs.add(p)
|
self.procs.add(p)
|
||||||
|
Reference in New Issue
Block a user