#How is the infinite loop maintained in tipsy.py code?
1 messages · Page 1 of 1 (latest)
Hi - the magic is here:
obstacle_task = asyncio.create_task(obstacle_detect_loop(sensor, sensor2, base))
person_task = asyncio.create_task(person_detect(detector, sensor, sensor2, base))
results= await asyncio.gather(obstacle_task, person_task, return_exceptions=True)
obstacle_task and person_task are functions that have never-terminating while loops. asyncio.gather() allows them to be run concurrently.
https://docs.python.org/3/library/asyncio-task.html#running-tasks-concurrently