def control_loop():
set_service_status(Service.CAPTURE, ServiceStatus.IDLE)<EOL>notify.notify('<STR_LIT>')<EOL>notify.notify('<STR_LIT>')<EOL>while not terminate():<EOL><INDENT>notify.notify('<STR_LIT>')<EOL>event = get_session().query(UpcomingEvent).filter(UpcomingEvent.start <= timestamp()).filter(UpcomingEvent.end > timestamp()).first()<EOL>if event:<EOL><INDENT>safe_start_capture(event)<EOL><DEDENT>time.sleep(<NUM_LIT:1.0>)<EOL><DEDENT>logger.info('<STR_LIT>')<EOL>set_service_status(Service.CAPTURE, ServiceStatus.STOPPED)<EOL>
Main loop of the capture agent, retrieving and checking the schedule as
    well as starting the capture process if necessry.