diff --git a/ansible_mitogen/affinity.py b/ansible_mitogen/affinity.py index 94539e21..eeeb4d38 100644 --- a/ansible_mitogen/affinity.py +++ b/ansible_mitogen/affinity.py @@ -142,7 +142,7 @@ class Policy(object): Assign the Ansible top-level policy to this process. """ - def assign_muxprocess(self): + def assign_muxprocess(self, index): """ Assign the MuxProcess policy to this process. """ @@ -224,7 +224,7 @@ class FixedPolicy(Policy): )) def _set_cpu(self, cpu): - self._set_affinity(1 << cpu) + self._set_affinity(1 << (cpu % self.cpu_count)) def _clear(self): all_cpus = (1 << self.cpu_count) - 1 @@ -236,8 +236,8 @@ class FixedPolicy(Policy): else: self._balance() - def assign_muxprocess(self): - self._set_cpu(0) + def assign_muxprocess(self, index): + self._set_cpu(index) def assign_worker(self): self._balance() diff --git a/ansible_mitogen/process.py b/ansible_mitogen/process.py index 7cdd68ae..a8052061 100644 --- a/ansible_mitogen/process.py +++ b/ansible_mitogen/process.py @@ -586,7 +586,7 @@ class MuxProcess(object): """ save_pid('mux') ansible_mitogen.logging.set_process_name('mux') - ansible_mitogen.affinity.policy.assign_muxprocess() + ansible_mitogen.affinity.policy.assign_muxprocess(self.index) self._setup_master() self._setup_services()