From 7b129e857627ca38d1ebc38b4b4396e8d560d7c1 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 30 Jan 2019 13:41:29 +0000 Subject: [PATCH] ansible: use Poller for WorkerProcess; closes #491. --- ansible_mitogen/connection.py | 12 +++++++++++- docs/changelog.rst | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 8bfbb51d..28afb099 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -44,6 +44,7 @@ import ansible.errors import ansible.plugins.connection import ansible.utils.shlex +import mitogen.core import mitogen.fork import mitogen.unix import mitogen.utils @@ -340,12 +341,21 @@ CONNECTION_METHOD = { } +class Broker(mitogen.master.Broker): + """ + WorkerProcess maintains at most 2 file descriptors, therefore does not need + the exuberant syscall expense of EpollPoller, so override it and restore + the poll() poller. + """ + poller_class = mitogen.core.Poller + + class CallChain(mitogen.parent.CallChain): """ Extend :class:`mitogen.parent.CallChain` to additionally cause the associated :class:`Connection` to be reset if a ChannelError occurs. - This only catches failures that occur while a call is pnding, it is a + This only catches failures that occur while a call is pending, it is a stop-gap until a more general method is available to notice connection in every situation. """ diff --git a/docs/changelog.rst b/docs/changelog.rst index e4458dc5..fa61ef0f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -174,6 +174,7 @@ Enhancements latency. * `#415 `_, + `#491 `_, `#493 `_: the interface employed for in-process queues changed from `kqueue `_ / `epoll