rainycode 1.5.8__tar.gz → 1.5.9__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.
- {rainycode-1.5.8 → rainycode-1.5.9}/PKG-INFO +1 -1
- {rainycode-1.5.8 → rainycode-1.5.9}/common_base/aiorequests.py +13 -3
- {rainycode-1.5.8 → rainycode-1.5.9}/pyproject.toml +1 -1
- {rainycode-1.5.8 → rainycode-1.5.9}/rainycode.egg-info/PKG-INFO +1 -1
- {rainycode-1.5.8 → rainycode-1.5.9}/common_base/consts.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_base/exception.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_base/logging.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_base/response.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_depends/auth_depend.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_models/__init__.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_models/base_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_models/file_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_models/user_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_models/wechat_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/api/auth_api.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/api/wechat_api.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/router.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/schemas/auth_schema.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/service/auth_svc.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/service/file_svc.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_servers/service/wechat_svc.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/bcrypt_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/captcha_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/datetime_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/ip_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/jwt_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/snowflake_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/common_utils/wechat_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/core/base_config.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/core/databases/aiodb.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/core/databases/aioredis.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/core/middleware/http_middleware.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/core/start.py +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/rainycode.egg-info/SOURCES.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/rainycode.egg-info/dependency_links.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/rainycode.egg-info/requires.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/rainycode.egg-info/top_level.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.5.9}/setup.cfg +0 -0
|
@@ -17,7 +17,9 @@ _CONNECTOR: aiohttp.TCPConnector | None = None
|
|
|
17
17
|
|
|
18
18
|
def _get_connector() -> aiohttp.TCPConnector:
|
|
19
19
|
global _CONNECTOR
|
|
20
|
-
|
|
20
|
+
# 判空之外还要判 closed:连接池一旦被别处关闭(见下方 connector_owner 说明),
|
|
21
|
+
# 这里能重建,避免后续所有请求都拿到已关闭的实例。
|
|
22
|
+
if _CONNECTOR is None or _CONNECTOR.closed:
|
|
21
23
|
_CONNECTOR = aiohttp.TCPConnector(ssl=_SSL_CONTEXT, limit=300, limit_per_host=100)
|
|
22
24
|
return _CONNECTOR
|
|
23
25
|
|
|
@@ -36,8 +38,13 @@ def parse_url(url, params=None, suffix=None):
|
|
|
36
38
|
|
|
37
39
|
async def get(url, params=None, headers=None, suffix=None):
|
|
38
40
|
url = parse_url(url, params, suffix)
|
|
41
|
+
# connector_owner=False 必须显式传:ClientSession 默认 owner=True,退出 async with 时
|
|
42
|
+
# 会连带 close 掉模块级共享的 _CONNECTOR;之后新 session 一建出来即 closed,
|
|
43
|
+
# session.get() 直接抛 RuntimeError: Session is closed(进程重启前不再自愈)。
|
|
39
44
|
async with (
|
|
40
|
-
aiohttp.ClientSession(
|
|
45
|
+
aiohttp.ClientSession(
|
|
46
|
+
connector=_get_connector(), trust_env=True, connector_owner=False
|
|
47
|
+
) as session,
|
|
41
48
|
session.get(url, headers=headers) as response,
|
|
42
49
|
):
|
|
43
50
|
text = await response.text()
|
|
@@ -47,8 +54,11 @@ async def get(url, params=None, headers=None, suffix=None):
|
|
|
47
54
|
async def post(url, data=None, headers=None):
|
|
48
55
|
if isinstance(data, dict):
|
|
49
56
|
data = json.dumps(data)
|
|
57
|
+
# connector_owner=False 的理由同 get():共享连接池不归单次 session 所有。
|
|
50
58
|
async with (
|
|
51
|
-
aiohttp.ClientSession(
|
|
59
|
+
aiohttp.ClientSession(
|
|
60
|
+
connector=_get_connector(), trust_env=True, connector_owner=False
|
|
61
|
+
) as session,
|
|
52
62
|
session.post(url, data=data, headers=headers) as response,
|
|
53
63
|
):
|
|
54
64
|
text = await response.text()
|
|
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
|
|
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
|