<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def atomic_symlink(src, dst):
 """Create or update a symbolic link atomically. This function is similar to :py:func:`os.symlink` but will update a symlink atomically."""


    dst_dir = os.path.dirname(dst)
    tmp = None
    max_tries = getattr(os, 'TMP_MAX', 10000)

    try:
        if not os.path.exists(dst_dir):
            os.makedirs(dst_dir)
        for n in range(max_tries):
            try:
                # mktemp is described as being unsafe. That is not true in this case since symlink is an
                # atomic operation at the file system level; if some other processes creates a file with
                # 'our' name then symlink will fail.
                tmp = tempfile.mktemp(dir=dst_dir)
                os.symlink(src, tmp)
                logger.debug('created symlink %s', tmp)
            except OSError as e:
                if e.errno == errno.EEXIST:
                    continue  # Someone else grabbed the temporary name first
                else:
                    raise
            logger.debug('renaming %s to %s', tmp, dst)
            os.rename(tmp, dst)
            return
    except:
        if tmp and os.path.exists(tmp):
            os.remove(tmp)
        raise
    raise IOError(errno.EEXIST, 'No usable temporary file name found')