当前位置: 首页>>代码示例>>Python>>正文


Python Task.loop方法代码示例

本文整理汇总了Python中task.Task.loop方法的典型用法代码示例。如果您正苦于以下问题:Python Task.loop方法的具体用法?Python Task.loop怎么用?Python Task.loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在task.Task的用法示例。


在下文中一共展示了Task.loop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_shakecast

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import loop [as 别名]
 def start_shakecast(self):
     try:
         status = ''
         message = ''
         task_names = [task.name for task in self.queue]
         if 'geo_json' not in task_names:
             task = Task()
             task.id = int(time.time() * 1000000)
             task.func = geo_json
             task.loop = True
             task.interval = 60
             task.db_use = True
             task.name = 'geo_json'
         
             self.queue += [task]
             message += 'Started monitoring earthquake feed \n'
         else:
             pass
         
         if 'check_new' not in task_names:
             task = Task()
             task.id = int(time.time() * 1000000)
             task.func = check_new
             task.loop = True
             task.interval = 3
             task.db_use = True
             task.name = 'check_new'
             
             self.queue += [task]
             message += "Waiting for new events"
         else:
             pass
         status = 'finished'
     except:
         status = 'failed'
     
     
     return {'status': status,
             'message': message}
开发者ID:LTurner-CT,项目名称:shakecast,代码行数:41,代码来源:server.py

示例2: start_shakecast

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import loop [as 别名]
    def start_shakecast(self):
        logging.info('Starting ShakeCast Server... ')
        try:
            status = ''
            message = ''
            task_names = [task.name for task in self.queue]

            if 'fast_geo_json' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.geo_json
                task.loop = True
                task.interval = 60
                task.db_use = True
                task.name = 'fast_geo_json'
                task.args_in = {'query_period': 'hour'}
            
                self.queue += [task]
                message += 'Started monitoring earthquake feed \n'
            
            if 'check_new' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.check_new
                task.loop = True
                task.interval = 3
                task.db_use = True
                task.name = 'check_new'
                
                self.queue += [task]
                message += "Waiting for new events"

            if 'check_for_updates' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.check_for_updates
                task.loop = True
                task.interval = 60
                task.name = 'check_for_updates'
                
                self.queue += [task]
                message += "Looking for updates"

            if 'record_messages' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = self.record_messages
                task.loop = True
                task.interval = 5
                task.name = 'record_messages'

                self.queue += [task]
                message += "Recording messages"

            status = 'finished'
        except:
            status = 'failed'
        
        
        return {'status': status,
                'message': message}
开发者ID:dslosky-usgs,项目名称:shakecast,代码行数:63,代码来源:server.py


注:本文中的task.Task.loop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。