sycommon-python-lib 0.2.2a5__py3-none-any.whl → 0.2.2a7__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.
@@ -388,7 +388,7 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
388
388
  session = await self._get_aiohttp_session()
389
389
 
390
390
  async def _do_request():
391
- async with session.post(url, json=data, headers=headers, timeout=aiohttp.ClientTimeout(total=http_timeout)) as resp:
391
+ async with session.post(url, json=data, headers=headers) as resp:
392
392
  SYLogger.info(f"[Sandbox] Async POST 响应状态码: {resp.status}")
393
393
  if resp.status >= 400:
394
394
  text = await resp.text()
@@ -486,9 +486,8 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
486
486
  # 从沙箱服务端 health 接口获取(aiohttp 异步)
487
487
  try:
488
488
  url = f"{self._base_url}{SANDBOX_API_PREFIX}/health"
489
- timeout_obj = aiohttp.ClientTimeout(total=10)
490
489
  session = await self._get_aiohttp_session()
491
- async with session.get(url, timeout=timeout_obj) as resp:
490
+ async with session.get(url) as resp:
492
491
  if resp.status == 200:
493
492
  data = await resp.json()
494
493
  workspace = data.get("workspace", "")
@@ -744,13 +743,12 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
744
743
  actual_timeout = timeout if timeout is not None else self._timeout
745
744
  url = f"{self._base_url}{SANDBOX_API_PREFIX}/execute_stream"
746
745
  session = await self._get_aiohttp_session()
747
- timeout_obj = aiohttp.ClientTimeout(total=actual_timeout + 60)
748
746
 
749
747
  async with session.post(url, json={
750
748
  "command": command.strip(),
751
749
  "user_id": self._user_id,
752
750
  "timeout": actual_timeout
753
- }, timeout=timeout_obj) as resp:
751
+ }) as resp:
754
752
  resp.raise_for_status()
755
753
  buffer = ""
756
754
  async for chunk in resp.content.iter_any():
@@ -858,7 +856,7 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
858
856
  results.append(FileUploadResponse(path=path, error=str(e)))
859
857
  return results
860
858
 
861
- async def aupload_files(self, files: List[tuple[str, bytes]]) -> List[FileUploadResponse]:
859
+ async def aupload_files(self, files: List[tuple[str, bytes]], *, timeout: int = None) -> List[FileUploadResponse]:
862
860
  """异步上传多个文件(真正的异步实现,使用 /batch_upload)"""
863
861
  if not files:
864
862
  return []
@@ -870,7 +868,7 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
870
868
  result = await self._post_async_with_failover(f"{SANDBOX_API_PREFIX}/batch_upload", {
871
869
  "files": batch,
872
870
  "user_id": self._user_id
873
- })
871
+ }, timeout=timeout)
874
872
  return [
875
873
  FileUploadResponse(path=r.get("path", ""), error=r.get("error"))
876
874
  for r in result.get("results", [])
@@ -884,7 +882,7 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
884
882
  "path": path,
885
883
  "content": base64.b64encode(content).decode(),
886
884
  "user_id": self._user_id
887
- })
885
+ }, timeout=timeout)
888
886
  results.append(FileUploadResponse(path=r["path"], error=r.get("error")))
889
887
  except Exception as ex:
890
888
  results.append(FileUploadResponse(path=path, error=str(ex)))
@@ -911,14 +909,15 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
911
909
  results.append(FileDownloadResponse(path=path, error=str(e)))
912
910
  return results
913
911
 
914
- async def adownload_files(self, paths: List[str]) -> List[FileDownloadResponse]:
912
+ async def adownload_files(self, paths: List[str], *, timeout: int = None) -> List[FileDownloadResponse]:
915
913
  """异步下载多个文件(真正的异步实现)"""
916
914
  results = []
917
915
  for path in paths:
918
916
  try:
919
917
  result = await self._post_async_with_failover(
920
918
  f"{SANDBOX_API_PREFIX}/download",
921
- {"path": path, "user_id": self._user_id}
919
+ {"path": path, "user_id": self._user_id},
920
+ timeout=timeout
922
921
  )
923
922
  if result.get("error"):
924
923
  results.append(FileDownloadResponse(
@@ -1303,8 +1302,7 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
1303
1302
  try:
1304
1303
  url = f"{self._base_url}{SANDBOX_API_PREFIX}/health"
1305
1304
  session = await self._get_aiohttp_session()
1306
- timeout_obj = aiohttp.ClientTimeout(total=10)
1307
- async with session.get(url, timeout=timeout_obj) as resp:
1305
+ async with session.get(url) as resp:
1308
1306
  resp.raise_for_status()
1309
1307
  result = await resp.json()
1310
1308
  SYLogger.info(f"[Sandbox] 异步健康检查成功: {result}")
@@ -77,7 +77,7 @@ def setup_trace_id_handler(app):
77
77
  "method": request.method,
78
78
  "url": str(request.url),
79
79
  "query_params": query_params,
80
- "request_body": request_body,
80
+ "request_body": request_body if not files_info else f"[文件上传] {list(files_info.values())}",
81
81
  "uploaded_files": files_info if files_info else None
82
82
  }
83
83
  SYLogger.info(json.dumps(request_message, ensure_ascii=False))
@@ -245,10 +245,13 @@ def setup_trace_id_handler(app):
245
245
  pass
246
246
 
247
247
  # 构建响应日志
248
+ response_log_body = response_body.decode('utf-8', errors='ignore')
249
+ if len(response_log_body) > 10000:
250
+ response_log_body = response_log_body[:10000] + f"... (truncated, total {len(response_body)} bytes)"
248
251
  response_message = {
249
252
  "traceId": trace_id,
250
253
  "status_code": response.status_code,
251
- "response_body": response_body.decode('utf-8', errors='ignore'),
254
+ "response_body": response_log_body,
252
255
  }
253
256
  SYLogger.info(json.dumps(response_message, ensure_ascii=False))
254
257
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.2.2a5
3
+ Version: 0.2.2a7
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -133,7 +133,7 @@ sycommon/agent/deep_agent.py,sha256=PUJpvGQNEIgE2TXBvb2i_ux_iDCIl-sQ8iqIS1skXRo,
133
133
  sycommon/agent/multi_agent_team.py,sha256=VIV4r_lxXB6ciLOsoFeF-99l8Rv1jWg4G6QpE5J4cBc,26106
134
134
  sycommon/agent/sandbox/__init__.py,sha256=qEgMJ2FFw0xJsA53M1Ji8kP6wIi_QkTICQYbWN-1h3M,4514
135
135
  sycommon/agent/sandbox/file_ops.py,sha256=AY9vi0285iYYpT8-Dzr9zu1uWgr3RNcdTk2KPXY0cfI,22888
136
- sycommon/agent/sandbox/http_sandbox_backend.py,sha256=tq7ktX8O-psQVFgfHdvLHbCiJFXacaCgd5rBgTLlatA,56347
136
+ sycommon/agent/sandbox/http_sandbox_backend.py,sha256=0rOsbUv5UJYxwwBujTrJ-32sYelTtnjbn1OTk1lqPpY,56165
137
137
  sycommon/agent/sandbox/sandbox_pool.py,sha256=eMn8sLakCWf90l6ni2-333QM8oBdX1CflV-WzneFp_k,9133
138
138
  sycommon/agent/sandbox/sandbox_recovery.py,sha256=VDhFI1q9DzSs5B3s2gee1mTmXQoxs0UCXzDrqNQ7VBY,7295
139
139
  sycommon/agent/sandbox/session.py,sha256=TjzC3yFC-VaJ75UwCyL26QX4PRTGNNfQae1FKFuOsYI,2365
@@ -199,7 +199,7 @@ sycommon/middleware/mq.py,sha256=9X6KKtadFjBXKS5L3kEKujYio9wwGfWgXwWOAHO-HDg,254
199
199
  sycommon/middleware/sandbox.py,sha256=1PA1E3WPP1_GLHyg0hxcQ47Cxo9ib_bhFg4F5yFjn9c,60802
200
200
  sycommon/middleware/timeout.py,sha256=KlxOPa8xl2dg6yuRi_EzkVJG8bX4stb5ueYxctzzGM8,1433
201
201
  sycommon/middleware/token_tracking.py,sha256=rEbgV1bgWMdzAERx4aq5XAvOIT6jTY_tK1P0xHJnL3o,6609
202
- sycommon/middleware/traceid.py,sha256=rJ6yLkYJi-x_Vq41xzkfAAc4xDts2IpPmDcKN8hYuv8,13065
202
+ sycommon/middleware/traceid.py,sha256=mUvx0TQUD6X3Qo0sOAaLXoC7KcCHz2BLWkKGZ3POves,13348
203
203
  sycommon/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
204
204
  sycommon/models/base_http.py,sha256=EICAAibx3xhjBsLqm35Mi3DCqxp0FME4rD_3iQVjT_E,3051
205
205
  sycommon/models/log.py,sha256=rZpj6VkDRxK3B6H7XSeWdYZshU8F0Sks8bq1p6pPlDw,500
@@ -253,8 +253,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
253
253
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
254
254
  sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
255
255
  sycommon/xxljob/xxljob_service.py,sha256=JIEJaGXhqrTLcyxlyynSrsHg9bBnDNzX-D4qIWLRPUE,6815
256
- sycommon_python_lib-0.2.2a5.dist-info/METADATA,sha256=oI-21bOsIGa6w5YvL46xxrvrnj2EOQLk5dH6EXaTwC0,7683
257
- sycommon_python_lib-0.2.2a5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
258
- sycommon_python_lib-0.2.2a5.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
259
- sycommon_python_lib-0.2.2a5.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
260
- sycommon_python_lib-0.2.2a5.dist-info/RECORD,,
256
+ sycommon_python_lib-0.2.2a7.dist-info/METADATA,sha256=Gf5CzRWkW4TvNxB4FdO9g6x5tUwVTM9Hv8RcPk_7ckg,7683
257
+ sycommon_python_lib-0.2.2a7.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
258
+ sycommon_python_lib-0.2.2a7.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
259
+ sycommon_python_lib-0.2.2a7.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
260
+ sycommon_python_lib-0.2.2a7.dist-info/RECORD,,