本文整理匯總了Python中gearman.GearmanClient.do_taskset方法的典型用法代碼示例。如果您正苦於以下問題:Python GearmanClient.do_taskset方法的具體用法?Python GearmanClient.do_taskset怎麽用?Python GearmanClient.do_taskset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gearman.GearmanClient
的用法示例。
在下文中一共展示了GearmanClient.do_taskset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_urls
# 需要導入模塊: from gearman import GearmanClient [as 別名]
# 或者: from gearman.GearmanClient import do_taskset [as 別名]
urls = get_urls(URLS_DB)
client = GearmanClient(["10.61.0.145"])
tasks = Taskset()
TASK_URLS_NUM = 100
# disptribute task
i = 0
while i < len(urls):
sub_urls = urls[i : i + TASK_URLS_NUM]
workload = "\n".join(sub_urls)
t = Task1("crawl", workload, str(i), timeout=TASK1_TIMEOUT, retry_count=1)
tasks.add(t)
print "add task:%s" % t.uniq
i += TASK_URLS_NUM
# test
pass
# 0.init database for return result from worker
print "0.initialize database for results."
tmps = ["%s int" % cate for cate in CATES]
cates_str = ",".join(tmps)
tb_sql = "create table %s (word text primary key,%s,total int);" % (RAW_WORDS_TB, cates_str)
print tb_sql
init_db(TASK1_RESULT_DB, tb_sql)
# 1.run the tasks in parallel
print "1.Preprocess tasks:"
client.do_taskset(tasks)
# 全局開方特征選擇--以下是單機版程序
# print "2.TSR by chi:"
# tsr_chi()