Failure Handling

import sys
sys.path.append('../python') # path to beecluster
import beecluster
from time import sleep
# test error handling and override flags api
def infinite_loop(bc):
bc.setFlags(True, True)
bc.act("flyto", (50,50,10))
while True:
bc.act("wifi:sense").val
sleep(1.0)
if __name__ == "__main__":
with beecluster.Session(appID = "TEST-5") as bc:
def error_handler(e):
print(e)
# Test timeout
bc.newTask(infinite_loop, bc, TaskName="loop", error_handler = error_handler, timeout = 5.0).val
# Test binding violation
# The drone will run out of battery and return to home, this
# will trigger the binding violation.
bc.newTask(infinite_loop, bc, TaskName="loop", error_handler = error_handler, timeout = None).val