tests: fixes mininode's P2PConnection sending messages on closing transport

- checks if  _transport.is_closing() (added in python3.4.4/python3.5.1)
before attempting to send messages on P2PConnection's send_message
method.
pull/13715/head
marcoagner 6 years ago
parent 4a3e8c5aa6
commit ea5340c9d2
No known key found for this signature in database
GPG Key ID: 0DC77FC61ED3ECC4

@ -179,7 +179,7 @@ class P2PConnection(asyncio.Protocol):
raise IOError('Not connected') raise IOError('Not connected')
self._log_message("send", message) self._log_message("send", message)
tmsg = self._build_message(message) tmsg = self._build_message(message)
NetworkThread.network_event_loop.call_soon_threadsafe(lambda: self._transport and self._transport.write(tmsg)) NetworkThread.network_event_loop.call_soon_threadsafe(lambda: self._transport and not self._transport.is_closing() and self._transport.write(tmsg))
# Class utility methods # Class utility methods

Loading…
Cancel
Save