Python: Multiprocessing imap & dynamically-created pools freeze
Question: Could someone explain why this code freezes (hangs forever),

    
    
    import multiprocessing
    def foo(x): return x
    def main():
        print(list(multiprocessing.Pool().imap(foo, iter([1, 2, 3]))))
    main()
    

While this variant works fine,

    
    
    import multiprocessing
    def foo(x): return x
    pool = multiprocessing.Pool()
    def main():
        print(list(pool.imap(foo, iter([1, 2, 3]))))
    main()
    

as with this one,

    
    
    import multiprocessing
    def foo(x): return x
    def main():
        print(list(multiprocessing.Pool().map(foo, [1, 2, 3])))
    main()
    

Incidentally, being able to dynamically create multiprocessing.Pool() at a
non-initialization stage in the application, and then use imap would be really
helpful. I tried stepping through it in `gdb`, and it seems frozen at
`PyThread_acquire_lock` ... but I feel pretty out-of-element debugging at such
a low level.


Answer: Apparently this is a bug with Python 2.6.7, and has been fixed at least by
Python 2.7.3.

This can be worked around by using my `vimap` package [
<https://github.com/gatoatigrado/vimap> ].

