From 5800383ba6032791697a225923e5d3e00b393c1f Mon Sep 17 00:00:00 2001 From: Crista Lopes Date: Fri, 27 Dec 2013 09:05:16 -0800 Subject: [PATCH] Switched the order of actions, so that the explanation flows better --- 16-dataspaces/tf-16.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/16-dataspaces/tf-16.py b/16-dataspaces/tf-16.py index aac4fa5..a22b385 100755 --- a/16-dataspaces/tf-16.py +++ b/16-dataspaces/tf-16.py @@ -23,16 +23,16 @@ def process_words(): word_freqs[word] = 1 freq_space.put(word_freqs) +# Let's have this thread populate the word space +for word in re.findall('[a-z]{2,}', open(sys.argv[1]).read().lower()): + word_space.put(word) + # Let's create the workers and launch them at their jobs workers = [] for i in range(5): workers.append(threading.Thread(target = process_words)) [t.start() for t in workers] -# Let's have this thread populate the word space -for word in re.findall('[a-z]{2,}', open(sys.argv[1]).read().lower()): - word_space.put(word) - # Let's wait for the workers to finish [t.join() for t in workers]