internal 1.1.9__py3-none-any.whl → 1.1.11__py3-none-any.whl

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.

Potentially problematic release.


This version of internal might be problematic. Click here for more details.

internal/http/requests.py CHANGED
@@ -24,11 +24,13 @@ async def invoke_request(timeout: httpx.Timeout, method: str, url: str, app: Fas
24
24
  )
25
25
  return response
26
26
  except httpx.TimeoutException as exc:
27
- app.state.logger.warn(f"invoke_request(), TimeoutException, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
27
+ message = f"invoke_request(), TimeoutException, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}"
28
+ app.state.logger.warn(message)
28
29
  raise GatewayTimeoutException(str(exc)) from exc
29
30
  except Exception as exc:
30
- app.state.logger.warn(
31
- f"invoke_request(), Exception, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
31
+ message = f"invoke_request(), Exception, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}"
32
+ app.state.logger.warn(message)
33
+ await send_webhook_message(app, message)
32
34
  raise BadGatewayException(str(exc))
33
35
 
34
36
 
@@ -76,7 +78,7 @@ async def async_request(app: FastAPI, method, url, current_user: dict = None,
76
78
  current_delay = float(request_retry_delay)
77
79
 
78
80
  while retries <= request_retry_count:
79
- app.state.logger.warn(f"嘗試送請求 (第 {retries + 1} 次嘗試)...")
81
+ app.state.logger.warn(f"url: {url}, method: {method}, kwargs: {kwargs}, 嘗試送請求 (第 {retries + 1} 次嘗試)...")
80
82
  try:
81
83
  # 使用 await 關鍵字等待異步請求完成
82
84
  response = await invoke_request(timeout, method, url, app, **kwargs)
@@ -85,18 +87,19 @@ async def async_request(app: FastAPI, method, url, current_user: dict = None,
85
87
  if retries < request_retry_count:
86
88
  # 計算下一次的延遲時間:current_delay * 2^retries + 隨機抖動
87
89
  sleep_time = current_delay * (2 ** retries) + random.uniform(0, 0.5)
88
- app.state.logger.warn(f"等待 {sleep_time:.2f} 秒後重試...")
90
+ app.state.logger.warn(f"url: {url}, method: {method}, kwargs: {kwargs}, 等待 {sleep_time:.2f} 秒後重試...")
89
91
  # 使用 asyncio.sleep 進行異步等待,不會阻塞主執行緒
90
92
  await asyncio.sleep(sleep_time)
91
93
  retries += 1
92
94
  else:
93
- app.state.logger.warn(f"已達到最大重試次數 ({request_retry_count}),放棄發送請求。")
95
+ message = f"url: {url}, method: {method}, kwargs: {kwargs}, 已達到最大重試次數 ({request_retry_count}),放棄發送請求。"
96
+ app.state.logger.warn(message)
94
97
  raise # 重新拋出最後一個異常
95
98
 
96
99
 
97
100
  async def invoke_webhook_message_api(app: FastAPI, message: str):
98
101
  payload = {"text": message}
99
- response = await async_request(app, "POST", app.state.config.WEBHOOK_BASE_URL, request_retry_count=0, json=payload)
102
+ response = await async_request(app, "POST", app.state.config.WEBHOOK_BASE_URL, json=payload)
100
103
  response.raise_for_status()
101
104
  return response
102
105
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: internal
3
- Version: 1.1.9
3
+ Version: 1.1.11
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -23,7 +23,7 @@ internal/ext/amazon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
23
23
  internal/ext/amazon/aws/__init__.py,sha256=2YFjb-rHG1JaZGZiZffYDesgTAJjDshOqQbswOYzhP8,834
24
24
  internal/ext/amazon/aws/const.py,sha256=l4WMg5bKWujwOKABBkCO2zclNg3abnYOfbhD7DG8GsA,109
25
25
  internal/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- internal/http/requests.py,sha256=84J3gDrlnFUxOxAqYkc_1nQOP0vlO4DJ5WBDQ0RXGmE,7660
26
+ internal/http/requests.py,sha256=JEblqezuQH2jMODUM9vEd0O8yfzOBV_O-htcVJkQt4I,7907
27
27
  internal/http/responses.py,sha256=zvU0iRQ9-qxeEZfKmuvTi8lv9DFcaNAsHlQKOTCpVzw,2945
28
28
  internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  internal/interface/base_interface.py,sha256=3YaVjIgLi_pZpLk5SEIk8WVkuICM8qPavT8rB0MdB5U,1536
@@ -34,6 +34,6 @@ internal/model/base_model.py,sha256=hxleV8fYNvFgUoYmCv_inEP3kA4tD4HhCBCNFVK8SZg,
34
34
  internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
35
35
  internal/utils.py,sha256=i6YZdiXsiWnOjRdlJ6afNCGpyMe3Uo9mhm3xlQBy3Ls,2824
36
36
  internal/validator_utils.py,sha256=CqjaVFoAu5MqvBG_AkTP-r7AliWawtUWB851USj4moI,1519
37
- internal-1.1.9.dist-info/METADATA,sha256=tITF_fGu6NGfSnUXn2iZTHkeRoSKIsY4BIh5idi9Obc,938
38
- internal-1.1.9.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
39
- internal-1.1.9.dist-info/RECORD,,
37
+ internal-1.1.11.dist-info/METADATA,sha256=62bJWUCU0Ty1dBYZ96QHuYpE8EzSQAqVgzsoOL76Mgk,939
38
+ internal-1.1.11.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
39
+ internal-1.1.11.dist-info/RECORD,,