# test.py # ------- # # Running this file in Python will work, # # $python test.py # [42] # # But importing this file from the interpreter will hang on the get(): # # $python # >>> import test # (... hangs ...) # # However, if we comment out run() (the last line in this file), # and instead call run() *AFTER* importing this file in the # interpreter, it will work: # # (... comment out 'run()' in the last line in this file ...) # $python # >>> import test # >>> test.run() # [42] # # (Tests were done on Ubuntu 9.10, which has Python 2.6.4rc2) from multiprocessing import Queue q = Queue() def run(): q.put([42]) print q.get() run()