Beispiel #1
0
    def status(self):
        try:
            updated_at = conn.get(self.updated_at.format(self.name))
            started_at = conn.get(self.started_at.format(self.name))
        except:
            return '?'

        if started_at is None:
            return '?'
        elif updated_at is None:
            return 'W'
        elif self.is_finished():
            return 'F'
        else:
            return 'P'
Beispiel #2
0
    def status(self):
        try:
            updated_at = conn.get(self.updated_at.format(self.name))
            started_at = conn.get(self.started_at.format(self.name))
        except:
            return '?'

        if started_at is None:
            return '?'
        elif updated_at is None:
            return 'W'
        elif self.is_finished():
            return 'F'
        else:
            return 'P'
Beispiel #3
0
    def duration(self):
        try:
            updated_at = conn.get(self.updated_at.format(self.name))
            started_at = conn.get(self.started_at.format(self.name))
        except:
            return '?'

        if updated_at and started_at:
            seconds = int(float(updated_at) - float(started_at))
            if seconds < 60:
                return '{}s'.format(seconds)
            elif seconds < 3600:
                return '{}m{}s'.format(seconds / 60, seconds % 60)
            elif seconds < 86400:
                return '{}h{}m'.format(seconds / 3600, seconds % 3600 / 60)
            elif seconds > 86400:
                return '{}d{}h'.format(seconds / 86400, seconds % 86400 / 3600)
        else:
            return '?'
Beispiel #4
0
 def is_finished(self):
     try:
         generation_complete = lambda : conn.get(self.generated.format(self.name)) == 'true'
         processing_complete = lambda : self.task_left() == 0
         finished = generation_complete() and processing_complete()
         if not finished:
             self.check_zombie()
         return finished
     except:
         return False
Beispiel #5
0
    def duration(self):
        try:
            updated_at = conn.get(self.updated_at.format(self.name))
            started_at = conn.get(self.started_at.format(self.name))
        except:
            return '?'

        if updated_at and started_at:
            seconds = int(float(updated_at)-float(started_at))
            if seconds < 60:
                return '{}s'.format(seconds)
            elif seconds < 3600:
                return '{}m{}s'.format(seconds/60, seconds%60)
            elif seconds < 86400:
                return '{}h{}m'.format(seconds/3600, seconds%3600/60)
            elif seconds > 86400:
                return '{}d{}h'.format(seconds/86400, seconds%86400/3600)
        else:
            return '?'
Beispiel #6
0
 def is_finished(self):
     try:
         generation_complete = lambda: conn.get(
             self.generated.format(self.name)) == 'true'
         processing_complete = lambda: self.task_left() == 0
         finished = generation_complete() and processing_complete()
         if not finished:
             self.check_zombie()
         return finished
     except:
         return False
Beispiel #7
0
 def check_zombie(self):
     try:
         updated_at = conn.get(self.updated_at.format(self.name))
         if updated_at:
             updated_at = float(updated_at)
             if (time.mktime(time.gmtime()) - updated_at) > 600:
                 while True:
                     task = conn.lpop(self.processing.format(self.name))
                     if task is None:
                         break
                     conn.rpush(self.dones.format(self.name), task)
     except:
         pass
Beispiel #8
0
 def check_zombie(self):
     try:
         updated_at = conn.get(self.updated_at.format(self.name))
         if updated_at:
             updated_at = float(updated_at)
             if (time.mktime(time.gmtime()) - updated_at) > 600:
                 while True:
                     task = conn.lpop(self.processing.format(self.name))
                     if task is None:
                         break
                     conn.rpush(self.dones.format(self.name), task)
     except:
         pass