Skip to content

Commit 9acc446

Browse files
author
Michele Simionato
committed
Backported fix to config.zworkers
1 parent 9af0416 commit 9acc446

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

openquake/baselib/workerpool.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_zworkers(job_id):
5656
hostcores = f.read()
5757
except FileNotFoundError:
5858
hostcores = ''
59-
return DotDict(ctrl_port=config.zworkers.ctrl_port,
59+
return DotDict(ctrl_port=config.zworkers['ctrl_port'],
6060
host_cores=hostcores.replace('\n', ',').rstrip(','))
6161
return {}
6262

@@ -66,8 +66,8 @@ def ssh_args(zworkers):
6666
:yields: triples (hostIP, num_cores, [ssh remote python command])
6767
"""
6868
user = getpass.getuser()
69-
if zworkers.host_cores.strip():
70-
for hostcores in zworkers.host_cores.split(','):
69+
if zworkers['host_cores'].strip():
70+
for hostcores in zworkers['host_cores'].split(','):
7171
host, cores = hostcores.split()
7272
if host == '127.0.0.1': # localhost
7373
yield host, cores, [sys.executable]
@@ -86,10 +86,10 @@ def __init__(self, zworkers, receiver_ports=None):
8686
else: # passed dictionary of strings
8787
self.zworkers = zworkers
8888
# NB: receiver_ports is not used but needed for compliance
89-
self.ctrl_port = int(self.zworkers.ctrl_port)
89+
self.ctrl_port = int(self.zworkers['ctrl_port'])
9090
self.host_cores = (
91-
[hc.split() for hc in self.zworkers.host_cores.split(',')]
92-
if self.zworkers.host_cores else [])
91+
[hc.split() for hc in self.zworkers['host_cores'].split(',')]
92+
if self.zworkers['host_cores'] else [])
9393
self.popens = []
9494

9595
def start(self):
@@ -175,7 +175,7 @@ def wait(self, seconds=120):
175175
"""
176176
Wait until all workers are active
177177
"""
178-
num_hosts = len(self.zworkers.host_cores.split(','))
178+
num_hosts = len(self.zworkers['host_cores'].split(','))
179179
for _ in range(seconds):
180180
time.sleep(1)
181181
status = self.status()
@@ -204,7 +204,8 @@ def debug(self):
204204
"""
205205
self.start()
206206
try:
207-
mon = performance.Monitor('zmq-debug')
207+
mon = performance.Monitor(
208+
'zmq-debug', dbserver_host=config.dbserver.host)
208209
mon.inject = True
209210
rec_host = config.dbserver.receiver_host or '127.0.0.1'
210211
receiver = 'tcp://%s:%s' % (
@@ -360,7 +361,7 @@ def workerpool(num_workers: int=-1, job_id: int=0):
360361
Start a workerpool with the given number of workers.
361362
"""
362363
# NB: unexpected errors will appear in the DbServer log
363-
wpool = WorkerPool(int(config.zworkers.ctrl_port), num_workers, job_id)
364+
wpool = WorkerPool(int(config.zworkers['ctrl_port']), num_workers, job_id)
364365
try:
365366
wpool.start()
366367
finally:

0 commit comments

Comments
 (0)