def queue_check(self): """ Check for tasks that are ready to be run and finished tasks that can be removed """ timestamp = time.time() for i,task in enumerate(self.queue): # run tasks if it's their time and they aren't already running if ((task.next_run < timestamp and task.status == 'stopped') and (task.db_use is False or self.db_open is True)): if task.db_use is True: self.db_open = False self.make_print('Running: %s' % task.name) self.last_task = time.time() task_thread = New_Thread(func=task.run) task_thread.start() # move task to the end of the list self.queue.pop(i) self.queue += [task] elif task.status == 'finished' or task.status == 'failed': self.check_task(task=task)
def queue_check(self): """ Check for tasks that are ready to be run and finished tasks that can be removed """ timestamp = time.time() for i, task in enumerate(self.queue): # run tasks if it's their time and they aren't already running if ((task.next_run < timestamp and task.status == 'stopped') and (task.db_use is False or self.db_open is True)): if task.db_use is True: self.db_open = False self.make_print('Running: %s' % task.name) self.last_task = time.time() task_thread = New_Thread(func=task.run) task_thread.start() # move task to the end of the list self.queue.pop(i) self.queue += [task] elif task.status == 'finished' or task.status == 'failed': self.check_task(task=task)
def socket_check(self): """ Check if any connections have been established """ conns = select_.select([self.socket], [], [], 0)[0] if len(conns) > 0: conn, addr = self.socket.accept() conn.setblocking(0) client_thread = New_Thread(func=self.handle_client, args_in={'conn': conn, 'addr': addr}) client_thread.start()
def socket_check(self): """ Check if any connections have been established """ conns = select_.select([self.socket], [], [], 0)[0] if len(conns) > 0: conn, addr = self.socket.accept() conn.setblocking(0) client_thread = New_Thread(func=self.handle_client, args_in={ 'conn': conn, 'addr': addr }) client_thread.start()