diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index 13861da633..36f39e470d 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -217,7 +217,17 @@ class P2PConnection(asyncio.Protocol): raise IOError('Not connected') self._log_message("send", message) tmsg = self._build_message(message) - NetworkThread.network_event_loop.call_soon_threadsafe(lambda: self._transport and not self._transport.is_closing() and self._transport.write(tmsg)) + + def maybe_write(): + if not self._transport: + return + # Python <3.4.4 does not have is_closing, so we have to check for + # its existence explicitly as long as Dash Core supports all + # Python 3.4 versions. + if hasattr(self._transport, 'is_closing') and self._transport.is_closing(): + return + self._transport.write(tmsg) + NetworkThread.network_event_loop.call_soon_threadsafe(maybe_write) # Class utility methods