def _download_part(path, session, url, retry, timeout, start_byte, end_byte):
    """
    Downloads a single part.
    :param path: File path.
    :param session: Requests session.
    :param url: Url of the resource.
    :param retry: Number of times to retry on error.
    :param timeout: Session timeout.
    :param start_byte: Start byte of the part.
    :param end_byte: End byte of the part.
    :return:
    """
    try:
        fp = os.open(path, os.O_CREAT | os.O_WRONLY)
    except IOError:
        raise SbgError('Unable to open file %s' % path)

    # Prepare range headers.
    headers = {}
    if end_byte is not None:
        headers['Range'] = 'bytes=%d-%d' % (int(start_byte), int(end_byte))

    cause = None

    # Retry
    for retry in range(retry):
        try:
            response = session.get(
                url, headers=headers, timeout=timeout, stream=True
            )
            response.raise_for_status()
            part_size = response.headers.get('Content-Length')
            os.lseek(fp, start_byte, os.SEEK_SET)
            for part in response.iter_content(32 * PartSize.KB):
                os.write(fp, part)
            os.close(fp)
        except requests.HTTPError as e:
            cause = e
            time.sleep(2 ** retry)
            continue
        except requests.RequestException as e:
            cause = e
            time.sleep(2 ** retry)
            continue
        else:
            return Part(start=start_byte, size=float(part_size))

    else:
        os.close(fp)
        raise SbgError('Failed to download file after {} attempts.'
                       ' Response: {}'.format(retry, six.text_type(cause)))
Downloads a single part.
    :param path: File path.
    :param session: Requests session.
    :param url: Url of the resource.
    :param retry: Number of times to retry on error.
    :param timeout: Session timeout.
    :param start_byte: Start byte of the part.
    :param end_byte: End byte of the part.
    :return: