10a8c90248264a8b26970b4473770bcc3df8515fJosh Gaoimport multiprocessing 20a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 30a8c90248264a8b26970b4473770bcc3df8515fJosh Gaodef foo(conn): 40a8c90248264a8b26970b4473770bcc3df8515fJosh Gao conn.send("123") 50a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 60a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Because "if __name__ == '__main__'" is missing this will not work 70a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# correctly on Windows. However, we should get a RuntimeError rather 80a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# than the Windows equivalent of a fork bomb. 90a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 100a8c90248264a8b26970b4473770bcc3df8515fJosh Gaor, w = multiprocessing.Pipe(False) 110a8c90248264a8b26970b4473770bcc3df8515fJosh Gaop = multiprocessing.Process(target=foo, args=(w,)) 120a8c90248264a8b26970b4473770bcc3df8515fJosh Gaop.start() 130a8c90248264a8b26970b4473770bcc3df8515fJosh Gaow.close() 140a8c90248264a8b26970b4473770bcc3df8515fJosh Gaoprint(r.recv()) 150a8c90248264a8b26970b4473770bcc3df8515fJosh Gaor.close() 160a8c90248264a8b26970b4473770bcc3df8515fJosh Gaop.join() 17