Skip to content

Commit 7445cce

Browse files
committed
fix tls issue by pinging most workers at startup to init connection pool
1 parent 9238874 commit 7445cce

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

scripts/extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Script(scripts.Script):
6161
world.save_config()
6262
# do an early check to see which workers are online
6363
logger.info("doing initial ping sweep to see which workers are reachable")
64-
world.ping_remotes()
64+
world.ping_remotes(indiscriminate=True)
6565

6666
def title(self):
6767
return "Distribute"

scripts/spartan/World.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,18 +561,28 @@ def save_config(self):
561561
config_file.write(config.json(indent=3))
562562
logger.debug(f"config saved")
563563

564-
def ping_remotes(self):
564+
def ping_remotes(self, indiscriminate: bool = False):
565+
"""
566+
Checks to see which workers are reachable over the network and marks those that are not as such
567+
568+
Args:
569+
indiscriminate: if True, also pings workers thought to already be reachable (State.IDLE)
570+
"""
565571
for worker in self._workers:
566572
if worker.master:
567573
continue
568574
if worker.state == State.DISABLED:
569575
logger.debug(f"refusing to ping disabled worker '{worker.label}'")
576+
continue
570577

571-
if worker.state == State.UNAVAILABLE:
572-
logger.debug(f"checking if worker '{worker.label}' is now reachable...")
578+
if worker.state == State.UNAVAILABLE or indiscriminate is True:
579+
logger.debug(f"checking if worker '{worker.label}' is reachable...")
573580
reachable = worker.reachable()
574581
if reachable:
575-
logger.info(f"worker '{worker.label}' is now online, marking as available")
582+
if worker.state == State.IDLE:
583+
continue
584+
585+
logger.info(f"worker '{worker.label}' is online, marking as available")
576586
worker.state = State.IDLE
577587
else:
578-
logger.info(f"worker '{worker.label}' is still unreachable")
588+
logger.info(f"worker '{worker.label}' is unreachable")

0 commit comments

Comments
 (0)