mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 09:55:12 +00:00
feat(downloader): fan large segment batches across worker processes
One CPython interpreter caps sustained segment throughput at ~160 MB/s; spawned children each run the existing thread-pool path on a contiguous chunk of the batch, reaching NIC line rate on fast CDNs. Opt-in via --download-processes (default 1), engaged only for 24+ segment batches. Sessions are rebuilt per child from a picklable spec; RnetSession falls back to a single process when it has no impersonate preset.
This commit is contained in:
@@ -568,6 +568,19 @@ class RnetSession:
|
||||
if "proxies" in session_kwargs:
|
||||
self.proxies.update(session_kwargs.pop("proxies"))
|
||||
|
||||
@property
|
||||
def impersonate_name(self) -> Optional[str]:
|
||||
"""Preset name (e.g. 'Chrome131') for rebuilding this session in another process.
|
||||
|
||||
rnet enums stringify as 'Impersonate.Chrome131'; return the trailing name, or None
|
||||
when no preset was set (then the session is not cheaply rebuildable across processes).
|
||||
"""
|
||||
preset = self._client_kwargs.get("impersonate")
|
||||
if preset is None:
|
||||
return None
|
||||
name = str(preset).rsplit(".", 1)[-1]
|
||||
return name or None
|
||||
|
||||
def _ensure_client(self) -> rnet.BlockingClient:
|
||||
"""Lazily create the rnet client on first use, flushing any buffered state."""
|
||||
if self._client is None:
|
||||
|
||||
Reference in New Issue
Block a user