Commit 50cfaf48 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

fix bug due to access to expiring

parent f6e29bc2
Pipeline #348701 passed with stage
in 14 seconds
......@@ -125,6 +125,7 @@ def add_user_def(func):
def __dir_syn(self):
while True:
try:
time.sleep(0.1)
old_dir_json = self.dir_json
self.to_dir_json()
......@@ -132,9 +133,12 @@ def __dir_syn(self):
continue
else:
self.dir.updateThingIDBased(thingID=self.thing_id, payload=self.dir_json)
except:
continue
def __repo_syn(self):
while self.__is_repo:
try:
time.sleep(0.1)
old_repo_json = self.repo_json
self.to_repo_json()
......@@ -142,6 +146,8 @@ def __repo_syn(self):
continue
else:
self.repo.updateThingIDBased(thingID=self.thing_id, payload=self.repo_json)
except:
continue
def __connect_with_idp(self):
print(BColors.OKBLUE + "[S³I][IdP]" + BColors.ENDC + ": Connect with S3I-IdentityProvider")
......@@ -165,7 +171,6 @@ def __on_token(self, token):
if self.__is_broker:
self.__connect_with_broker()
def __connect_with_dir(self):
print(
BColors.OKBLUE
......@@ -223,7 +228,7 @@ def __on_websocket_connection_closed(self):
)
def sync_with_repo(self, path, topic):
#TODO
# TODO
if not self.__ws_connected:
return None
msg = {"topic": topic, "path": path, "value": self.repo_json[path]}
......@@ -237,12 +242,17 @@ def __connect_with_broker(self):
def receive():
while True:
try:
time.sleep(0.1)
msg_str = self.broker.receive_once(self.__endpoint)
if msg_str == "":
continue
else:
self.__on_broker_callback(ch=None, method=None, properties=None,
body=json.loads(msg_str))
except:
continue
threading.Thread(
target=receive
).start()
......@@ -423,11 +433,8 @@ def on_service_request(self, body_json):
replyingToUUID=body_json.get("identifier", None),
msgUUID="s3i:{}".format(uuid.uuid4())
)
receiver_eps = list()
for r in service_reply.msg.get("receivers", None):
receiver_ep = find_broker_endpoint(self.dir, r)
receiver_eps.append(receiver_ep)
self.broker.send(receiver_endpoints=receiver_eps, msg=json.dumps(service_reply.msg))
self.broker.send(receiver_endpoints=[body_json.get("replyToEndpoint", None)],
msg=json.dumps(service_reply.msg))
def on_get_value_reply(self, msg):
print(
......@@ -500,5 +507,3 @@ def to_subthing_json(self):
for key in self.features.keys():
json_out["features"].append(self.features[key].to_json())
return json_out
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment