import gevent.monkey
gevent.monkey.patch_all()
def write_to_file(file_name, text):
text = str(text)
a = open(file_name, 'a')
a.write(text + "
")
a.close()
def foo(i,a,b,c):
print i,a,b,c
# gevent.sleep(0)
write_to_file("a",i)
print "Done"
task = [gevent.spawn(foo,i,1,2,3) for i in range(1000000)]
gevent.joinall(task)
坑点
https://www.jianshu.com/p/861f29ac68e8