summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1030eeb)
bundles scheduled on the same machine as their primary.
def acquire_worker(self, machine_to_avoid=None) -> Optional[RemoteWorkerRecord]:
grabbag = []
for worker in self.workers:
def acquire_worker(self, machine_to_avoid=None) -> Optional[RemoteWorkerRecord]:
grabbag = []
for worker in self.workers:
- for x in range(0, worker.count):
- for y in range(0, worker.weight):
- grabbag.append(worker)
-
- for _ in range(0, 5):
- random.shuffle(grabbag)
- worker = grabbag[0]
- if worker.machine != machine_to_avoid or _ > 2:
+ if worker.machine != machine_to_avoid:
- worker.count -= 1
- logger.debug(f'Selected worker {worker}')
- return worker
- msg = 'Unexpectedly could not find a worker, retrying...'
- logger.warning(msg)
- return None
+ for _ in range(worker.count * worker.weight):
+ grabbag.append(worker)
+
+ if len(grabbag) == 0:
+ logger.debug(
+ f'There are no available workers that avoid {machine_to_avoid}...'
+ )
+ for worker in self.workers:
+ if worker.count > 0:
+ for _ in range(worker.count * worker.weight):
+ grabbag.append(worker)
+
+ if len(grabbag) == 0:
+ logger.warning('There are no available workers?!')
+ return None
+
+ worker = random.sample(grabbag, 1)[0]
+ assert worker.count > 0
+ worker.count -= 1
+ logger.debug(f'Chose worker {worker}')
+ return worker
class RoundRobinRemoteWorkerSelectionPolicy(RemoteWorkerSelectionPolicy):
class RoundRobinRemoteWorkerSelectionPolicy(RemoteWorkerSelectionPolicy):
) = self.run_periodic_heartbeat()
@background_thread
) = self.run_periodic_heartbeat()
@background_thread
- def run_periodic_heartbeat(self, stop_event) -> None:
+ def run_periodic_heartbeat(self, stop_event: threading.Event) -> None:
while not stop_event.is_set():
time.sleep(5.0)
logger.debug('Running periodic heartbeat code...')
while not stop_event.is_set():
time.sleep(5.0)
logger.debug('Running periodic heartbeat code...')
logger.debug('Periodic heartbeat thread shutting down.')
def heartbeat(self) -> None:
logger.debug('Periodic heartbeat thread shutting down.')
def heartbeat(self) -> None:
+ # Note: this is invoked on a background thread, not an
+ # executor thread. Be careful what you do with it b/c it
+ # needs to get back and dump status again periodically.
- # Dump regular progress report
self.status.periodic_dump(self.total_bundles_submitted)
# Look for bundles to reschedule via executor.submit
self.status.periodic_dump(self.total_bundles_submitted)
# Look for bundles to reschedule via executor.submit
if (
num_done > 2
and num_idle_workers > 1
if (
num_done > 2
and num_idle_workers > 1
- and (self.last_backup is None or (now - self.last_backup > 6.0))
+ and (self.last_backup is None or (now - self.last_backup > 9.0))
and self.backup_lock.acquire(blocking=False)
):
try:
and self.backup_lock.acquire(blocking=False)
):
try:
RemoteWorkerRecord(
username='scott',
machine='cheetah.house',
RemoteWorkerRecord(
username='scott',
machine='cheetah.house',
RemoteWorkerRecord(
username='scott',
machine='puma.cabin',
RemoteWorkerRecord(
username='scott',
machine='puma.cabin',
RemoteWorkerRecord(
username='scott',
machine='backup.house',
RemoteWorkerRecord(
username='scott',
machine='backup.house',