diff --git a/testing/marionette/client/marionette_driver/transport.py b/testing/marionette/client/marionette_driver/transport.py index 97dcdee1c6fd..679b14562fd7 100644 --- a/testing/marionette/client/marionette_driver/transport.py +++ b/testing/marionette/client/marionette_driver/transport.py @@ -305,8 +305,10 @@ class TcpTransport(object): if exc.errno not in (57, 107): raise - self._sock.close() - self._sock = None + if self._sock: + # Guard against unclean shutdown. + self._sock.close() + self._sock = None def __del__(self): self.close()