Пример #1
0
def test_task(task):
    """
    Dummy task for basic testing.
    """
    time.sleep(task)
    log.debug("test_task[" + str(task) + "] called")            

    
Пример #2
0
 def __init__(self, task_name):
     if task_name in _TASK_NAMES:
         self.task_name = task_name
         log.debug('Task created: ' + task_name)
     else:
         self.task_name = 'UNKNOWN'
         log.debug('Task created: ' + task_name)
     self.is_subtask = False
     self.subtask_count = 0
     self.created = time.time()
     self.last_update = self.created
Пример #3
0
 def run(self):
     """
     Start worker.
     """
     log.info("worker started")
     while True:
         task_name, _callable, args, kwds = self.task_queue.get()
         log.debug("worker got " + task_name)
         # pylint: disable-msg=W0142
         results = _callable(*args, **kwds)
         # pylint: enable-msg=W0142
         if results is False:
             log.error("Task failed: " + task_name)
Пример #4
0
    def run(self):
        """
        Check the tasks queue and run anything that is due.
        """
        while True:
            while self.current_workers < self.total_workers:
                log.debug("worker added")
                core.worker.Worker(self.active_queue)
                self.current_workers += 1

            self.process_pending_list()
            self.process_active_list()
            self.process_done_list()

            log.info("active_queue = " + str(self.active_queue.qsize()))
            time.sleep(core.config.TIMER_SLEEP_INTERVAL)
            log.debug("waking")
Пример #5
0
def start_database():
    """
    This isn't robust. If the file doesn't exist this call just creates it. We neeed to find
    a better way to open to file or check for it's existence.
    maybe something like:
       dbdir = os.path.dirname(path)
       if not os.access(path, os.R_OK + os.W_OK) or
           not os.access(dbdir, os.R_OK + os.W_OK):
    WARNING: need to investiage thread safety
    """
    con = sqlite.connect(core.config.DBFILE)
 
    if con:
        cur = con.cursor()

        # Execute the SELECT statement:
        cur.execute("select * from monrito_systems")

        # Retrieve all rows as a sequence and print that sequence:
        log.debug(cur.fetchall())
        return True
    else:
        return False