It is said in officail documentation methods decorated with @start in flow get executed parallelly but i am trying using crewai chatgpt assistance. It is not working. unexpectedly, 1 in 20 execution it works. I am not able to figure out the reason.
Here is flow i have written :
class Realtime86Flow(Flow[Realtime86State]):
"""Real Time 86 Flow Implementation"""
def __init__(self):
"""Initialize the flow with optional parameters"""
super().__init__()
@start()
async def coordinator_task(self)->str:
print("Inside Coordinator RealTime86 flow")
crew = CoordinatorCrew().crew()
tick = {"action": "publishing :REALTIME_86_TRIGGER"}
await crew.kickoff_async(inputs={
"topic": "realtime86.trigger",
"message": tick
})
return "Coordinator Done"
@start()
async def inventory_sensor_task(self)->str:
print("Inside Inventory RealTime86 flow")
crew = InventorySensorCrew().crew()
await crew.kickoff_async(inputs={
"subscriber_topic": "realtime86.trigger",
"publisher_topic": "low.stock.items",
"failure_topic": "86.failures"
})
return "Inventory Sensor Done"
@listen(and_(coordinator_task,inventory_sensor_task))
def is_realtime86_activated(self,is_activated)->None:
print(f"Outside @start : {"RealTime86 Activated"}")
logger.info(f"Outside @start : {"RealTime86 Activated"}")
# # Keep main thread alive if needed
# while True:
# time.sleep(10)