python多重流程 協程的正確姿勢是什麼?下面這段程式碼算不算多行程和協程結合的例子?
from multiprocessing import Pool
import gevent
def test1():
print (12)
gevent.sleep(1)
print (34)
def test2():
print (56)
gevent.sleep(1)
print (78)
def coroutine():
gevent.joinall([
gevent.spawn(test1),
gevent.spawn(test2)
])
if __name__=="__main__":
p=Pool()
for i in range(3):
p.apply_async(coroutine,args=())
p.close()
p.join()
加補丁就算完整了.