Why my subprocess generated by pool.apply_async() always run as MainProcess?
<p>My env is Python2.7.I am very fuzzed,I run my apply_async(test_func),and I let the test_func print the current process_name.As like:</p>

<pre><code>q = Queue(maxsize=20) #multiprocessing.Queue

def test_func(queue):
    print 'Process'
    print multiprocessing.current_process()

if __name__ == '__main__':
    pool = Pool(processes=3)
    for i in xrange(3):
        pool.apply_async(test_func(q,))
    while True:
        time.sleep(1)
        if q.empty():
            break
        print 'Main Process Monitoring'
        print multiprocessing.current_process()
</code></pre>

<p>The code has no syntax error,and the terminal always print <code>&lt;MainProcess&gt;</code> </p>

<p>If I change <code>pool.apply_async(test_func,(q,))(add a comma)</code>,it couldn't get into the <code>test_func</code>,just like simply finish for loop,and it just print <code>'Main Process Monitoring' &lt;MainProcess&gt;</code>..</p>

<p>So I can't understand why <code>apply_async()</code> can't work normally and when it work,it runs as <code>MainProcess</code>,and I have tried <code>pool.close(),pool.join()</code>.Nothing change.
If anyone can help.Thanks a lot!</p>

<p>Occasionally,I know that I should use <code>apply_async(test_func, (i,))</code>,and this is a mistake for me.</p>

<p>But what very odd is that,when I usse <code>apply_async(test_func, (q,))</code>,it will not work.the <code>q</code> is multiprocessing.Queue().If I remove it or substitute for any other except Queue object,it will work(print subprocess normally)</p>

<p>I don't know whether the Queue has some errors or something else raise...</p>

<p>Does any one knows that?Thanks a lot!</p>

python