|
8 | 8 | from cognit.models._device_runtime import Call |
9 | 9 | from statemachine import StateMachine, State |
10 | 10 |
|
| 11 | +from threading import Event |
11 | 12 | import sys |
12 | 13 |
|
13 | 14 | sys.path.append(".") |
@@ -64,7 +65,7 @@ class DeviceRuntimeStateMachine(StateMachine): |
64 | 65 | token_not_valid_ready = ready.to(init, unless=["is_cfc_connected"]) |
65 | 66 | token_not_valid_ready_2 = ready.to(init, unless=["is_ecf_connected"]) |
66 | 67 | # 4.3 The requirements have changed, therefore, the requirements are uploaded again |
67 | | - ready_update_requirements = ready.to(send_init_request, cond=["is_cfc_connected", "is_ecf_connected", "have_requirements_changed"]) |
| 68 | + ready_update_requirements = ready.to(send_init_request, cond=["is_cfc_connected", "is_ecf_connected", "have_requirements_changed"], unless=["is_new_ecf_address_set"]) |
68 | 69 | # 4.4 Connect to the Edge Cluster Frontend Client if the address has changed |
69 | 70 | ready_update_ecf_address = ready.to(get_ecf_address, cond=["is_cfc_connected", "is_ecf_connected", "is_new_ecf_address_set"], unless=["have_requirements_changed"]) |
70 | 71 |
|
@@ -97,6 +98,7 @@ def __init__(self, config: CognitConfig, requirements: Scheduling, call_queue: C |
97 | 98 | self.call_queue = call_queue |
98 | 99 | self.sync_results_queue = sync_result_queue |
99 | 100 |
|
| 101 | + self.update_ecf_address_event = Event() |
100 | 102 | super().__init__() |
101 | 103 |
|
102 | 104 | # Get credentials by instantiating a CognitFrontendClient and authenticates to the Cognit Frontend |
@@ -222,11 +224,7 @@ def get_new_ecf_address(self): |
222 | 224 | """ |
223 | 225 | Get the new Edge Cluster Frontend address from the CFC. |
224 | 226 | """ |
225 | | - self.new_ecf_address = self.cfc._get_edge_cluster_address() |
226 | | - |
227 | | - if self.new_ecf_address == self.ecc_address: |
228 | | - self.logger.debug("New ECF address is the same as the current one") |
229 | | - self.new_ecf_address = None |
| 227 | + self.update_ecf_address_event.set() |
230 | 228 |
|
231 | 229 | # Checks if CF client has connection with the CF |
232 | 230 | def is_cfc_connected(self): |
|
0 commit comments