When I use gevent and it's still synchronous and run time doesn't decrease.
Here is my script:
def fun(i):
p = subprocess.Popen(['./main', 'data.txt'], stdout=PIPE, stderr=PIPE)
err = p.communicate()[1]
p.wait()
def synchronous():
for i in range(1,10):
fun(i)
def asynchronous():
threads = [gevent.spawn(fun, i) for i in xrange(10)]
gevent.joinall(threads)
By comparing %timeit synchronous()
and %timeit asynchronous()
, there is little change. And the 'main' is the compiled c++ file and the 'data.txt' is the input file for 'main'.
I guess the problem is that I use subprocess to call a external routine, but I don't know how to solve this problem.