本文整理汇总了Python中task.Task.run方法的典型用法代码示例。如果您正苦于以下问题:Python Task.run方法的具体用法?Python Task.run怎么用?Python Task.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task.Task
的用法示例。
在下文中一共展示了Task.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_func_called
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
def test_func_called(self):
func = Mock()
func.return_value = "ok"
t = Task(func, "hello", hello="world")
t.run()
func.assert_called_once_with(t)
self.assertEqual(t.result, "ok")
示例2: test_func_can_recv_data
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
def test_func_can_recv_data(self):
def func(t):
return t.queue.get()
t = Task(func)
t.send("ok")
t.run()
self.assertEqual(t.result, "ok")
示例3: App
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
class App(object):
def __init__(self):
self.db = configs.create_engine()
self.page_manager = db.PageManager(db=self.db)
self.references_manager = db.ReferencesManager(db=self.db)
self.worker_count = configs.WORKER_COUNT
self.downloader = Downloader()
self.parser = Parser()
self.task_queue = QueueTask(
page_manager=self.page_manager,
size=4 * self.worker_count)
self.task = Task(
page_manager=self.page_manager,
references_manager=self.references_manager,
task_queue=self.task_queue,
worker_count=self.worker_count,
parser=self.parser,
downloader=self.downloader
)
def run(self):
signal.signal(
signal.SIGINT, (lambda signum, frame: self.task_queue.stop()))
self.task.run()
示例4: main
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
def main():
task = Task()
try:
optlist, args = getopt.getopt(sys.argv[1:], 'cxo:',
['compress', 'extract', 'output='])
processArgs(optlist, args, task)
except getopt.GetoptError as e:
print str(e)
usage()
return
task.run()
示例5: App
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
class App(object):
def __init__(self):
self.db = create_engine()
self.task = Task(db=self.db)
def run(self):
signal.signal(
signal.SIGINT, (lambda signum, frame: self.task.stop()))
# self.task._insert_urls_best_muzon()
# self.task._insert_urls_pesni_tut()
try:
self.task.run()
except Exception:
pass
示例6: test_func_exc_caught
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import run [as 别名]
def test_func_exc_caught(self):
def func(t):
raise Exception("ok")
t = Task(func, "hello", hello="world")
t.run()
self.assertEqual(t.exception.message, "ok")