yuzhibott's recent timeline updates
yuzhibott

yuzhibott

V2EX member #249367, joined on 2017-08-18 09:26:34 +08:00
yuzhibott's recent replies
@lesmiserables0 不能这么骗别人的 23333
Aug 23, 2018
Replied to a topic by CarsonChen 情感问题 面对这样的前女友,我该怎么做?
不知道楼上为啥说滚床单,要是我肯定没这心情
@shibingsw 多个定时任务啊,每个定时不一样,join 不是只能一个一个线程执行么
num = 0

def test1(*data):
global num
i = data[0]
while True:
if num == 10:
num = 0
break
print(i)
num += 1
time.sleep(2)

def test2(*data):
i = data[0]
threading.Thread(target=test1, args=(i,)).start()
print("done")

pool = multiprocessing.Pool(processes=5)
for j in range(2):
pool.apply_async(test2, (j,))
大概代码如上,不能用 join(),因为实际中是多任务定时处理,每个任务时间不一样
num = 0

def test1(*data):
global num
i = data[0]
while True:
if num == 10:
num = 0
break
print(i)
num += 1
time.sleep(2)

def test2(*data):
i = data[0]
threading.Thread(target=test1, args=(i,)).start()
print("done")

pool = multiprocessing.Pool(processes=5)
for j in range(2):
pool.apply_async(test2, (j,))
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6073 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 03:33 · PVG 11:33 · LAX 20:33 · JFK 23:33
♥ Do have faith in what you're doing.