From 5811909c8dd89c0efdc08a8261885e8e1469df32 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 4 Aug 2019 11:46:53 +0100 Subject: [PATCH] [linear2] simplify _listener_for_name() --- ansible_mitogen/process.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ansible_mitogen/process.py b/ansible_mitogen/process.py index 2b29904e..0c59e833 100644 --- a/ansible_mitogen/process.py +++ b/ansible_mitogen/process.py @@ -480,12 +480,9 @@ class ClassicWorkerModel(WorkerModel): Given an inventory hostname, return the UNIX listener that should communicate with it. This is a simple hash of the inventory name. """ - if len(self._muxes) == 1: - return self._muxes[0].path - - idx = abs(hash(name)) % len(self._muxes) - LOG.debug('Picked worker %d: %s', idx, self._muxes[idx].path) - return self._muxes[idx].path + mux = self._muxes[abs(hash(name)) % len(self._muxes)] + LOG.debug('Picked worker %d: %s', mux.index, mux.path) + return mux.path def _reconnect(self, path): if self.router is not None: