本文整理汇总了Python中task.Task.start方法的典型用法代码示例。如果您正苦于以下问题:Python Task.start方法的具体用法?Python Task.start怎么用?Python Task.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task.Task
的用法示例。
在下文中一共展示了Task.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_func_is_stopped
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import start [as 别名]
def test_func_is_stopped(self):
def func(t):
while not t.stopped():
time.sleep(0.1)
return "stopped"
t = Task(func)
t.start()
time.sleep(0.1)
t.stop()
time.sleep(0.1)
self.assertEqual(t.result, "stopped")
示例2: on_button_clicked
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import start [as 别名]
def on_button_clicked(self):
i = 0
children = self.m_table.get_children()
for child in children:
a = self.m_table.item(child)
addr = a["values"][1]
delay = i * 0.45
task = Task(i, addr, delay, self.on_update_task_info)
task.start()
self.m_mutex.acquire()
self.m_tasks[task] = child
self.m_mutex.release()
i += 1
#import time
#time.sleep(0.2)
import threading
self.m_thread = threading.Thread(target=self.thread_func, args=[self])
self.m_thread.setDaemon(True)
self.m_thread.start()
示例3: simple_task
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import start [as 别名]
import time
from task import Task
def simple_task(t):
assert t.args[0] == "hello"
assert t.kwargs['world'] == "world"
while not t.stopped():
time.sleep(0.1) # do some work
return "done."
if __name__ == "__main__":
t = Task(simple_task, "hello", world="world")
t.start()
# after 1 second signal our task to stop
time.sleep(1)
t.stop()
print t.result
示例4: start
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import start [as 别名]
def start(task: Task):
global g_procs
g_procs.update({task.name: _new_task_proc(task)})
verbose(2, 'proc pool added with:', g_procs[task.name])
task.start()