p115client 0.0.5.9.1__tar.gz → 0.0.5.9.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/PKG-INFO +1 -1
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/pool.py +22 -12
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/pyproject.toml +1 -1
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/LICENSE +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/__init__.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/_upload.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/client.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/const.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/exception.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/py.typed +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/__init__.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/download.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/edit.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/export_dir.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/fs_files.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/history.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/iterdir.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/life.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/request.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/upload.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/tool/xys.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/p115client/type.py +0 -0
- {p115client-0.0.5.9.1 → p115client-0.0.5.9.2}/readme.md +0 -0
@@ -6,12 +6,12 @@ from __future__ import annotations
|
|
6
6
|
__author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
7
7
|
__all__ = [
|
8
8
|
"generate_auth_factory", "generate_cookies_factory", "generate_client_factory",
|
9
|
-
"auth_pool", "cookies_pool", "client_pool", "call_wrap_with_pool",
|
9
|
+
"make_pool", "auth_pool", "cookies_pool", "client_pool", "call_wrap_with_pool",
|
10
10
|
]
|
11
11
|
__doc__ = "这个模块提供了一些和 cookies 池有关的函数"
|
12
12
|
|
13
13
|
from asyncio import Lock as AsyncLock
|
14
|
-
from collections.abc import Callable, Iterable
|
14
|
+
from collections.abc import Callable, Iterable, Mapping
|
15
15
|
from functools import partial, total_ordering, update_wrapper
|
16
16
|
from heapq import heappop, heappush, heapify
|
17
17
|
from itertools import cycle, repeat
|
@@ -365,23 +365,33 @@ def call_wrap_with_pool(get_cert_headers: Callable, /, func: Callable) -> Callab
|
|
365
365
|
:param get_cert_headers: 获取认证信息的请求头的函数
|
366
366
|
:param func: 执行请求的函数
|
367
367
|
"""
|
368
|
-
def wrapper(
|
368
|
+
def wrapper(
|
369
|
+
*args,
|
370
|
+
headers: None | Mapping = None,
|
371
|
+
async_: bool = False,
|
372
|
+
**kwds,
|
373
|
+
):
|
369
374
|
def gen_step():
|
370
375
|
nonlocal headers
|
371
376
|
while True:
|
372
377
|
if async_:
|
373
|
-
|
378
|
+
cert, revert = yield get_cert_headers(async_=True)
|
374
379
|
else:
|
375
|
-
|
376
|
-
if headers:
|
377
|
-
headers = dict(headers, **cert_headers)
|
378
|
-
else:
|
379
|
-
headers = cert_headers
|
380
|
+
cert, revert = get_cert_headers()
|
380
381
|
try:
|
381
|
-
if
|
382
|
-
|
382
|
+
if isinstance(cert, Mapping):
|
383
|
+
if headers:
|
384
|
+
headers = dict(headers, **cert)
|
385
|
+
else:
|
386
|
+
headers = cert
|
387
|
+
if async_:
|
388
|
+
resp = yield func(*args, headers=headers, async_=True, **kwds)
|
389
|
+
else:
|
390
|
+
resp = func(*args, headers=headers, **kwds)
|
391
|
+
elif async_:
|
392
|
+
resp = yield func(cert, *args, headers=headers, async_=True, **kwds)
|
383
393
|
else:
|
384
|
-
resp = func(*args, headers=headers, **kwds)
|
394
|
+
resp = func(cert, *args, headers=headers, **kwds)
|
385
395
|
if not isinstance(resp, dict) or resp.get("errno") != 40101004:
|
386
396
|
revert()
|
387
397
|
return resp
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|