# SessionConfig

class parfive.SessionConfig(http_proxy=None, https_proxy=None, headers=<factory>, chunksize=1024, file_progress=True, notebook=None, log_level=None, use_aiofiles=False, timeouts=None, aiohttp_session_generator=None, env=<factory>, done_callbacks=())

  Bases: `object`

  Configuration options for `parfive.Downloader`.

  Attributes Summary

  `aiohttp_session_generator` | A function to override the generation of the `aiohttp.ClientSession` object.
  `chunksize` | The default chunksize to be used for transfers over HTTP.
  `done_callbacks` | A list of functions to be called when a download is completed.
  `file_progress` | If `True` (the default) a progress bar will be shown (if any progress bars are shown) for every file, in addition for one showing progress of downloading all file.
  `http_proxy` | The URL of a proxy to use for HTTP requests.
  `https_proxy` | The URL of a proxy to use for HTTPS requests.
  `log_level` | If not `None` configure the logger to log to stderr with this log level.
  `notebook` | Override automatic detection of Jupyter notebook for drawing progress bars.
  `timeouts` | The `aiohttp.ClientTimeout` object to control the timeouts used for all HTTP requests.
  `use_aiofiles` | Enables using `aiofiles` to write files to disk in their own thread pool.

  Attributes Documentation

  aiohttp_session_generator: `Optional`[`Callable`[[`SessionConfig`], `ClientSession`]] = None

    A function to override the generation of the `aiohttp.ClientSession` object.

    Due to the fact that this session needs to be instantiated inside the asyncio context this option is a function. This function takes one argument which is the instance of this `SessionConfig` class. It is expected that you pass the `.headers` attribute of the config instance through to the `headers=` keyword argument of the session you instantiate.

  chunksize: `float` = 1024

    The default chunksize to be used for transfers over HTTP.

  done_callbacks: `Iterable`[`Callable`[[`str`, `str`, `Optional`[`Exception`]], `None`]] = ()

    A list of functions to be called when a download is completed.

    The signature of the function to be called is `f(filepath: str, url: str, error: Optional[Exception])`. If successful, error will be None, else the occured exception or asyncio.CancelledError.

  file_progress: `bool` = True

    If `True` (the default) a progress bar will be shown (if any progress bars are shown) for every file, in addition for one showing progress of downloading all file.

  http_proxy: `Optional`[`str`] = None

    The URL of a proxy to use for HTTP requests. Will default to the value of the `HTTP_PROXY` env var.

  https_proxy: `Optional`[`str`] = None

    The URL of a proxy to use for HTTPS requests. Will default to the value of the `HTTPS_PROXY` env var.

  log_level: `Optional`[`str`] = None

    If not `None` configure the logger to log to stderr with this log level.

  notebook: `Optional`[`bool`] = None

    Override automatic detection of Jupyter notebook for drawing progress bars. If `None` `tqdm` will automatically detect if it can draw rich notebook progress bars. If `False` or `True` notebook mode will be forced off or on.

  timeouts: `Optional`[`ClientTimeout`] = None

    The `aiohttp.ClientTimeout` object to control the timeouts used for all HTTP requests.

    By default the `total` timeout is set to `0` (never timeout) and the `sock_read` timeout is set to `90` seconds. These defaults can also be overridden by the `PARFIVE_TOTAL_TIMEOUT` and `PARFIVE_SOCK_READ_TIMEOUT` environment variables.

  use_aiofiles: `Optional`[`bool`] = False

    Enables using `aiofiles` to write files to disk in their own thread pool.

    The default value is `False`.

    This argument will be overridden by the `PARFIVE_OVERWRITE_ENABLE_AIOFILES` environment variable. If `aiofiles` can not be imported then this will be set to `False`.