rainycode 1.5.7__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.7 → rainycode-1.5.9}/PKG-INFO +1 -1
- {rainycode-1.5.7 → rainycode-1.5.9}/common_base/aiorequests.py +13 -3
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/service/auth_svc.py +2 -2
- {rainycode-1.5.7 → rainycode-1.5.9}/pyproject.toml +1 -1
- {rainycode-1.5.7 → rainycode-1.5.9}/rainycode.egg-info/PKG-INFO +1 -1
- {rainycode-1.5.7 → rainycode-1.5.9}/common_base/consts.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_base/exception.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_base/logging.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_base/response.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_depends/auth_depend.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_models/__init__.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_models/base_model.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_models/file_model.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_models/user_model.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_models/wechat_model.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/api/auth_api.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/api/wechat_api.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/router.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/schemas/auth_schema.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/service/file_svc.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_servers/service/wechat_svc.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/bcrypt_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/captcha_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/datetime_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/ip_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/jwt_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/snowflake_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/common_utils/wechat_util.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/core/base_config.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/core/databases/aiodb.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/core/databases/aioredis.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/core/middleware/http_middleware.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/core/start.py +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/rainycode.egg-info/SOURCES.txt +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/rainycode.egg-info/dependency_links.txt +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/rainycode.egg-info/requires.txt +0 -0
- {rainycode-1.5.7 → rainycode-1.5.9}/rainycode.egg-info/top_level.txt +0 -0
- {rainycode-1.5.7 → 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()
|
|
@@ -179,7 +179,7 @@ class AuthService:
|
|
|
179
179
|
|
|
180
180
|
# 构建回调地址
|
|
181
181
|
api_prefix = f"/api/{base_config.app_name}" if base_config.app_name else ""
|
|
182
|
-
callback_url = f"{base_config.base_url}{api_prefix}/wechat/callback"
|
|
182
|
+
callback_url = f"{base_config.base_url}{api_prefix}/wechat/oauth/callback"
|
|
183
183
|
|
|
184
184
|
return WechatUtil.build_oauth_url(
|
|
185
185
|
appid=app_config.app_id,
|
|
@@ -278,7 +278,7 @@ class AuthService:
|
|
|
278
278
|
|
|
279
279
|
# 构建 snsapi_userinfo 授权链接
|
|
280
280
|
api_prefix = f"/api/{base_config.app_name}" if base_config.app_name else ""
|
|
281
|
-
callback_url = f"{base_config.base_url}{api_prefix}/wechat/callback"
|
|
281
|
+
callback_url = f"{base_config.base_url}{api_prefix}/wechat/oauth/callback"
|
|
282
282
|
userinfo_auth_url = WechatUtil.build_oauth_url(
|
|
283
283
|
appid=wechat_app.app_id,
|
|
284
284
|
redirect_uri=callback_url,
|
|
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
|