Python Queue double threading
<p>I am trying to run 5 threads which run another 10 threads each. Something like:</p>

<pre><code>dictionaryFileQueue = Queue.Queue()
with open(dictionaryFile, "r") as wordsToCheck:
    for word in wordsToCheck:
        dictionaryFileQueue.put(word)

for wordToScan in wordsList:
#...some code

    dictionaryFileOpen = dictionaryFileQueue

    for i in range(10):
        i_thread = Thread(target=words_Scan_Start, args=(dictionaryFileOpen, wordToScan))
        threads.append(i_thread)

for thread in threads:
    for wordThread in thread:
        wordThread.start()

def words_Scan_Start(dictionaryFile, wordToScan):
    # Here I need to make an action with "wordToScan".
    # But in 10 threads "range(10)" and use the same "dictionaryFileOpen" for every thread.
    #...............
</code></pre>

<p>BUT, I need that each <code>wordToSacn</code> thread uses its own <code>dictionaryFileQueue</code>, which is comes from common source (<code>dictionaryFileQueue</code> at first line). Because when I'm starting all the threads, it all use just one Queue. But I need copy of Queue for every <code>wordToScan</code>. How can I make each <code>wordToScan</code> uses only copy of Queue and start its enumeration from the first line? How to make it use its own Queue which is coming from the common source?</p>

<p>It turns out, that was so easy to do.
Just need to paste this part:</p>

<pre><code>dictionaryFileQueue = Queue.Queue()

for word in linesOfDictionary:
    dictionaryFileQueue.put(word.strip())
</code></pre>

<p>Inside of this part:</p>

<pre><code>for wordToScan in wordsList:
#...some code

    # INSTEAD OF THIS LINE BELOW
    #dictionaryFileOpen = dictionaryFileQueue
</code></pre>

<p>And add this code at the begining of the script:</p>

<pre><code>openDictionaryFile = open(dictionaryFile, "r")
linesOfDictionary = openDictionaryFile.readlines()
openDictionaryFile.close()
</code></pre>

<p>instead of:</p>

<pre><code>#dictionaryFileQueue = Queue.Queue()
#with open(dictionaryFile, "r") as wordsToCheck:
    #for word in wordsToCheck:
        #dictionaryFileQueue.put(word)
</code></pre>

python multithreading queue