devicehive-python icon indicating copy to clipboard operation
devicehive-python copied to clipboard

send notification

Open CodePythonFollow opened this issue 5 years ago • 0 comments

Every time I send a message through the send_notification function, the thread is still not over even if I disconnect. Do I have to manually close the current thread?

self.device_hive_api = DeviceHiveApi(self.rest_url, login=self.login, password=self.password) while need_send_to_device_hive: msg = need_send_to_device_hive.pop() try: self.device_hive_api.send_notification(device_id, msg['notification'], msg['parameters']) # logging.info(msg['notification'], result.timestamp) except Exception as e: msg = { "notification": "error", "parameters": { "msg": str(e) } } need_send_to_device_hive.append(msg) self.device_hive_api = DeviceHiveApi(self.rest_url, login=self.login, password=self.password) self.device_hive_api.disconnect() threading.Timer(1, self.send_notification).start()

CodePythonFollow avatar Dec 23 '20 06:12 CodePythonFollow