Commits

Ask Solem  committed 95d1360

disconnect() must work even if the connection is lost

  • Participants
  • Parent commits 9015476

Comments (0)

Files changed (1)

File stompy/stomp.py

 
     def disconnect(self, conf=None):
         """Disconnect from the server."""
-        conf = conf or {}
-        for destination in self._subscribed_to.keys():
-            self.unsubscribe({"destination": destination})
-        self._send_command("DISCONNECT", conf)
+        try:
+            for destination in self._subscribed_to.keys():
+                self.unsubscribe({"destination": destination})
+            self._send_command("DISCONNECT", conf)
+        except self.NotConnectedError:
+            pass
         self.sock.shutdown(0)
         self.connected = False