Wait for connection to entityident

This commit is contained in:
2021-06-13 22:59:06 +02:00
parent c36a3e1d85
commit 8b0a60d9ab
2 changed files with 26 additions and 18 deletions
+13 -8
View File
@@ -21,6 +21,8 @@ sys.modules['target_velocity'] = target_velocity
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
SCALING = 1
class Orchestrator:
# vehicle ids
@@ -38,15 +40,18 @@ class Orchestrator:
# re-use http session, is faster then request.ing everytime
self._session = requests.Session()
try:
response = self._session.get(ENTITY_IDENT_URL + 'cars')
cars = response.json()
available = False
while not available:
try:
response = self._session.get(ENTITY_IDENT_URL + 'cars')
cars = response.json()
response = self._session.get(ENTITY_IDENT_URL + 'traffic_lights')
traffic_lights = response.json()
except requests.exceptions.ConnectionError as e:
print("Is the entity_ident_server running and reachable?")
raise e
response = self._session.get(ENTITY_IDENT_URL + 'traffic_lights')
traffic_lights = response.json()
except requests.exceptions.ConnectionError as e:
print("Is the entity_ident_server running and reachable?")
continue
available = True
for car in cars['cursor']:
self.vins.append(car['vin'])