fix circuitbreaker exception
This commit is contained in:
parent
8e5580ca7b
commit
4c87baf225
@ -9,6 +9,7 @@ from circuitbreaker import circuit
|
||||
from dse_shared_libs.traffic_light_color import TrafficLightColor
|
||||
from dse_shared_libs.message_broker_wrapper import MBWrapper
|
||||
from dse_shared_libs.traffic_light_state import TrafficLightState
|
||||
from pika.exceptions import AMQPConnectionError
|
||||
|
||||
SWITCHING_TIME = 500
|
||||
# Scale speed of switching by factor x
|
||||
@ -65,7 +66,7 @@ class TrafficLight:
|
||||
def stop(self):
|
||||
self.running = False
|
||||
|
||||
@circuit(failure_threshold=10, expected_exception=ConnectionError)
|
||||
@circuit(failure_threshold=10, expected_exception=AMQPConnectionError)
|
||||
def send_status_update(self):
|
||||
print(self.tlid, self.current_color, self.last_switch)
|
||||
self._tl_mb.send(pickle.dumps(
|
||||
@ -78,10 +79,10 @@ if __name__ == '__main__':
|
||||
tl1 = TrafficLight(tlid='traffic-light-1', switching_time=SWITCHING_TIME)
|
||||
tl1.start()
|
||||
|
||||
# time.sleep(1)
|
||||
# tl2 = TrafficLight(tlid='traffic-light-2', switching_time=240)
|
||||
# tl2.start()
|
||||
#
|
||||
# time.sleep(1)
|
||||
# tl3 = TrafficLight(tlid='traffic-light-3', switching_time=360)
|
||||
# tl3.start()
|
||||
time.sleep(1)
|
||||
tl2 = TrafficLight(tlid='traffic-light-2', switching_time=240)
|
||||
tl2.start()
|
||||
|
||||
time.sleep(1)
|
||||
tl3 = TrafficLight(tlid='traffic-light-3', switching_time=360)
|
||||
tl3.start()
|
||||
|
||||
@ -13,6 +13,7 @@ from dse_shared_libs.message_broker_wrapper import MBWrapper
|
||||
|
||||
# Lat, Long
|
||||
from dse_shared_libs.target_velocity import TargetVelocity
|
||||
from pika.exceptions import AMQPConnectionError
|
||||
|
||||
STARTING_POINT = geopy.Point(48.853, 2.349)
|
||||
# in km/h
|
||||
@ -202,7 +203,7 @@ class Vehicle:
|
||||
self.last_update = datetime.now()
|
||||
self.nce = False
|
||||
|
||||
@circuit(failure_threshold=10, expected_exception=ConnectionError)
|
||||
@circuit(failure_threshold=10, expected_exception=AMQPConnectionError)
|
||||
def send_status_update(self):
|
||||
print(self.driven_kms, '\t', self.daf)
|
||||
self._daf_mb.send(pickle.dumps(self.daf))
|
||||
@ -220,10 +221,10 @@ if __name__ == "__main__":
|
||||
v1 = Vehicle(vin='SB164ABN1PE082000')
|
||||
v1.start_driving()
|
||||
|
||||
# time.sleep(1)
|
||||
# v2 = Vehicle(vin='SB999ABN1PE082111')
|
||||
# v2.start_driving()
|
||||
#
|
||||
# time.sleep(0.5)
|
||||
# v3 = Vehicle(vin='SB555ABN1PE082555')
|
||||
# v3.start_driving()
|
||||
time.sleep(1)
|
||||
v2 = Vehicle(vin='SB999ABN1PE082111')
|
||||
v2.start_driving()
|
||||
|
||||
time.sleep(0.5)
|
||||
v3 = Vehicle(vin='SB555ABN1PE082555')
|
||||
v3.start_driving()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user