from multiprocessing import Pool
def action(i):
#takes a long time to be achieve
worker_pool = Pool(processes=1)
while True:
i = raw_input("Input your value: ")
result = worker_pool.apply_async(action, [i], callback)
你也可以用芹菜做背景任务:
@celery_app.task(bind=True,max_retries=None)
def action(i):
#takes a long time to be achieve
while True:
i = raw_input("Input your value: ")
action.apply_async(args=[i])
使用多处理模块:
你也可以用芹菜做背景任务:
相关问题 更多 >
编程相关推荐