From 5a69a56036c3de38d3c60312896fdd0817073f81 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 2 Oct 2010 21:46:32 +0200 Subject: [PATCH] Improved parallelization Version:1.1.53 --- src/util.py | 13 ++++++------- src/version.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util.py b/src/util.py index fa86659..5296b14 100644 --- a/src/util.py +++ b/src/util.py @@ -24,7 +24,7 @@ # 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr -NTHREADS=3 +NTHREADS=16 def strip(x): return x.strip() @@ -130,7 +130,7 @@ def put_info(text,filename): import cPickle as pickle import os, sys def parallel_loop(f,source): - pidlist = {} + pidlist = range(NTHREADS) src = [ [] for i in xrange(NTHREADS) ] index = 0 @@ -145,20 +145,19 @@ def parallel_loop(f,source): if fork == 0: break else: - import time - time.sleep(1) - pidlist[i] = fork + pidlist[thread_id] = fork thread_id = 0 - print "fork : ", fork, thread_id for filename, text in src[thread_id]: result = f(filename,text) file = open('%s.pickle'%filename,'w') pickle.dump(result,file,-1) file.close() + + if fork == 0: sys.exit(0) - for i in xrange(NTHREADS): + for i in xrange(1,NTHREADS): os.waitpid(pidlist[i],0) result = [] diff --git a/src/version.py b/src/version.py index 1cf2e84..96f991f 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.52" +version = "1.1.53"