本文整理汇总了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}
示例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}