def wait_until_file_exists(filename):
start_time = time.time()<EOL>time_limit = start_time + FILE_IO_TIMEOUT<EOL>while time.time() < time_limit:<EOL><INDENT>try:<EOL><INDENT>with open(filename):<EOL><INDENT>return<EOL><DEDENT><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>raise Timeout("<STR_LIT>" % filename)<EOL>
Wait until a file exists.

    :param filename: The name of the file to wait for.
    :type filename: string