예제 #1
0
 def disconnect(self):
     # Return disconnect succeeded/failed
     ret = False
     # Disconnect
     self._pahoClient.disconnect()  # Throw exception...
     TenmsCount = 0
     while (TenmsCount != self._connectdisconnectTimeout * 100
            and self._disconnectResultCode == sys.maxsize):
         TenmsCount += 1
         time.sleep(0.01)
     if (self._disconnectResultCode == sys.maxsize):
         self._log.error("Disconnect timeout.")
         raise disconnectTimeoutException()
     elif (self._disconnectResultCode == 0):
         ret = True
         self._log.info("Disconnected.")
         self._log.debug("Disconnect time consumption: " +
                         str(float(TenmsCount) * 10) + "ms.")
         self._pahoClient.loop_stop(
         )  # Do NOT maintain a background thread for socket communication since it is a successful disconnect
     else:
         self._log.error("A disconnect error happened: " +
                         str(self._disconnectResultCode))
         raise disconnectError(self._disconnectResultCode)
     return ret
예제 #2
0
 def disconnect_async(self, ack_callback=None):
     self._logger.info("Performing async disconnect...")
     self._client_status.set_status(ClientStatus.USER_DISCONNECT)
     rc = self._internal_async_client.disconnect(ack_callback)
     if MQTT_ERR_SUCCESS != rc:
         self._logger.error("Disconnect error: %d", rc)
         raise disconnectError(rc)
     return FixedEventMids.DISCONNECT_MID
예제 #3
0
 def disconnect_async(self, ack_callback=None):
     self._logger.info("Performing async disconnect...")
     self._client_status.set_status(ClientStatus.USER_DISCONNECT)
     rc = self._internal_async_client.disconnect(ack_callback)
     if MQTT_ERR_SUCCESS != rc:
         self._logger.error("Disconnect error: %d", rc)
         raise disconnectError(rc)
     return FixedEventMids.DISCONNECT_MID
 def disconnect(self):
     # Return disconnect succeeded/failed
     ret = False
     # Disconnect
     self._pahoClient.disconnect()  # Throw exception...
     TenmsCount = 0
     while(TenmsCount != self._connectdisconnectTimeout * 100 and self._disconnectResultCode == sys.maxsize):
         TenmsCount += 1
         time.sleep(0.01)
     if(self._disconnectResultCode == sys.maxsize):
         self._log.error("Disconnect timeout.")
         raise disconnectTimeoutException()
     elif(self._disconnectResultCode == 0):
         ret = True
         self._log.info("Disconnected.")
         self._log.debug("Disconnect time consumption: " + str(float(TenmsCount) * 10) + "ms.")
         self._pahoClient.loop_stop()  # Do NOT maintain a background thread for socket communication since it is a successful disconnect
     else:
         self._log.error("A disconnect error happened: " + str(self._disconnectResultCode))
         raise disconnectError(self._disconnectResultCode)
     return ret