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:
object
Configuration options for
parfive.Downloader
.Attributes Summary
A function to override the generation of the
aiohttp.ClientSession
object.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
None
configure the logger to log to stderr with this log level.Override automatic detection of Jupyter notebook for drawing progress bars.
The
aiohttp.ClientTimeout
object to control the timeouts used for all HTTP requests.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 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_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. IfFalse
orTrue
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 to0
(never timeout) and thesock_read
timeout is set to90
seconds. These defaults can also be overridden by thePARFIVE_TOTAL_TIMEOUT
andPARFIVE_SOCK_READ_TIMEOUT
environment variables.
-
aiohttp_session_generator: