From be4f1bdb50ea0751d04737fc71387d98f13f5402 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 11 Sep 2019 19:58:20 +0100 Subject: [PATCH] issue #646: add extra logging to assertions and start_child() --- ansible_mitogen/services.py | 3 ++- mitogen/core.py | 7 ++++--- mitogen/parent.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index 0c06d806..52171903 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -347,7 +347,8 @@ class ContextService(mitogen.service.Service): ) def _send_module_forwards(self, context): - self.router.responder.forward_modules(context, self.ALWAYS_PRELOAD) + if hasattr(self.router.responder, 'forward_modules'): + self.router.responder.forward_modules(context, self.ALWAYS_PRELOAD) _candidate_temp_dirs = None diff --git a/mitogen/core.py b/mitogen/core.py index 87388620..8a0855ee 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -503,7 +503,7 @@ def set_cloexec(fd): :func:`mitogen.fork.on_fork`. """ flags = fcntl.fcntl(fd, fcntl.F_GETFD) - assert fd > 2 + assert fd > 2, 'fd %r <= 2' % (fd,) fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC) @@ -808,7 +808,7 @@ class Message(object): self.src_id = mitogen.context_id self.auth_id = mitogen.context_id vars(self).update(kwargs) - assert isinstance(self.data, BytesType) + assert isinstance(self.data, BytesType), 'Message data is not Bytes' def pack(self): return ( @@ -1834,7 +1834,8 @@ class DelimitedProtocol(Protocol): if cont: self.on_partial_line_received(self._trailer) else: - assert stream.protocol is not self + assert stream.protocol is not self, \ + 'stream protocol is no longer %r' % (self,) stream.protocol.on_receive(broker, self._trailer) def on_line_received(self, line): diff --git a/mitogen/parent.py b/mitogen/parent.py index 1c3e1874..437f6c28 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1680,6 +1680,7 @@ class Connection(object): try: self.proc = self.start_child() except Exception: + LOG.debug('failed to start child', exc_info=True) self._fail_connection(sys.exc_info()[1]) return