def dup2(a, b, timeout=<NUM_LIT:3>):
dup_err = None<EOL>for i in range(int(<NUM_LIT:10> * timeout)):<EOL><INDENT>try:<EOL><INDENT>return os.dup2(a, b)<EOL><DEDENT>except OSError as e:<EOL><INDENT>dup_err = e<EOL>if e.errno == errno.EBUSY:<EOL><INDENT>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>if dup_err:<EOL><INDENT>raise dup_err<EOL><DEDENT>
Like os.dup2, but retry on EBUSY