def run(self): m = ftp.Master() headers = [self.num_workers, settings.CONTROLLER_LOOP_SLEEP_TIME, settings.FTP_CONNECT_TIMEOUT_SECS, settings.LAYMAN_TIMEOUT_SECS] while True: try: if Emerge.worker_needs_update(): print "Got update notification" self.updates += 1 with open('results.csv', 'a') as csvfile: writer = csv.writer(csvfile) writer.writerow(headers + [1, 0, 0]) if m.pick_job(): print "Got job" self.jobs += 1 with open('results.csv', 'a') as csvfile: writer = csv.writer(csvfile) writer.writerow(headers + [0, 1, 0]) time.sleep(settings.CONTROLLER_LOOP_SLEEP_TIME) except Exception: print "An Error occured" self.errors += 1 with open('results.csv', 'a') as csvfile: writer = csv.writer(csvfile) writer.writerow(headers + [0, 0, 1])