run-all wait all processes before returning
This commit is contained in:
parent
68cc7d635b
commit
cfd3e500fe
3 changed files with 8 additions and 4 deletions
|
@ -27,7 +27,7 @@ and setup your python environment.
|
|||
```bash
|
||||
sudo -i
|
||||
pip3 install --user .
|
||||
( cd scenarios && pip3 install -r requirements.txt )
|
||||
( cd scenarios && pip3 install --user -r requirements.txt )
|
||||
```
|
||||
|
||||
Sometimes, it is required to add manually your local python lib folder to the environment:
|
||||
|
|
8
mknet
8
mknet
|
@ -315,6 +315,7 @@ def runall(cmd):
|
|||
zones = parse(config).zones
|
||||
|
||||
number = 1
|
||||
wait_list = [ ]
|
||||
for zone in zones.values():
|
||||
if zone.is_zone():
|
||||
for server in zone.servers.values():
|
||||
|
@ -325,7 +326,7 @@ def runall(cmd):
|
|||
env["ID"] = str(number)
|
||||
env["SERVER_COUNT"] = str(len(config['servers']))
|
||||
name = f'testnet-{zone.name}-{server.name}'
|
||||
net.ns.run(name, cmd, env)
|
||||
wait_list.append(net.ns.run(name, cmd, env))
|
||||
number +=1
|
||||
else:
|
||||
env = os.environ.copy()
|
||||
|
@ -335,9 +336,12 @@ def runall(cmd):
|
|||
env["ID"] = str(number)
|
||||
env["SERVER_COUNT"] = str(len(config['servers']))
|
||||
name = f'testnet-{zone.name}-{zone.name}'
|
||||
net.ns.run(name, cmd, env)
|
||||
wait_list.append(net.ns.run(name, cmd, env))
|
||||
first = False
|
||||
number +=1
|
||||
for p in wait_list:
|
||||
p.wait()
|
||||
print("runall done")
|
||||
|
||||
def destroy():
|
||||
for ns in net.ns.list():
|
||||
|
|
2
net.py
2
net.py
|
@ -37,7 +37,7 @@ class ns:
|
|||
run_netns("exec", name, "ip", "link", "set", "dev", "lo", "up")
|
||||
|
||||
def run(name, cmd, env=None):
|
||||
subprocess.Popen(_netns + ["exec", name] + cmd, env=env)
|
||||
return subprocess.Popen(_netns + ["exec", name] + cmd, env=env)
|
||||
|
||||
def create_bridge(name, namespace, ports=[]):
|
||||
run_netns("exec", namespace, "ip", "link", "add", "name", name, "type", "bridge")
|
||||
|
|
Loading…
Reference in a new issue