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=())[source]#
Bases:
objectConfiguration options for
parfive.Downloader.Attributes Summary
A function to override the generation of the
aiohttp.ClientSessionobject.The default chunksize to be used for transfers over HTTP.
A list of functions to be called when a download is completed.
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.The URL of a proxy to use for HTTP requests.
The URL of a proxy to use for HTTPS requests.
If not
Noneconfigure the logger to log to stderr with this log level.Override automatic detection of Jupyter notebook for drawing progress bars.
The
aiohttp.ClientTimeoutobject to control the timeouts used for all HTTP requests.Enables using
aiofilesto 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.ClientSessionobject.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
SessionConfigclass. It is expected that you pass the.headersattribute of the config instance through to theheaders=keyword argument of the session you instantiate.
-
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_PROXYenv var.
-
https_proxy:
Optional[str] = None# The URL of a proxy to use for HTTPS requests. Will default to the value of the
HTTPS_PROXYenv var.
-
log_level:
Optional[str] = None# If not
Noneconfigure 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
Nonetqdmwill automatically detect if it can draw rich notebook progress bars. IfFalseorTruenotebook mode will be forced off or on.
-
timeouts:
Optional[ClientTimeout] = None# The
aiohttp.ClientTimeoutobject to control the timeouts used for all HTTP requests.By default the
totaltimeout is set to0(never timeout) and thesock_readtimeout is set to90seconds. These defaults can also be overridden by thePARFIVE_TOTAL_TIMEOUTandPARFIVE_SOCK_READ_TIMEOUTenvironment variables.
-
aiohttp_session_generator: