* fix(pool): 服务器中途掉线不再拖垮整批任务 三种调度细节会把「一台机器坏了」放大成「整批卡住」: 1. acquire() 在池锁内做 TCP 握手 + 探针 —— 一台主机握手卡满 timeout, 所有并发协程的 acquire/release 一起被挡。改为锁内只预留槽位、 握手在锁外做,失败时回滚计数。 2. 扩容失败分支 continue 且无截止检查 —— 全节点失联时无限重试, 永远不抛 PoolTimeoutError。改为同一次 acquire 内每台主机只试一遍, 试完立刻抛错;再加池级熔断(BLACKOUT_COOLDOWN=2s),期内直接失败, 任一连接成功即解除。否则上层「按标的逐只重试」会把 16×6000 次握手 放大成 60s+ 的空转。 3. 批量 K 线失败批次攒到 gather 结束再串行补 —— 每只重付一次 RTT。 改为 extendleft 回队首由健康连接立刻接手(每只最多 2 次), 尾部兜底也改成信号量并发。分页器同理:worker 退出时把剩余页放回 共享 leftover,活着的 worker 接手,全部退出后仍有剩页则借新连接补完。 EX 池同步改为锁外建连,并给握手失败主机加 30s 拉黑。 实测(16 台替身节点、6000 只 × 240 根 1 分钟 K 线、0.9s 后变黑洞): 无故障 1.79s → 1.80s 2/16 死 2.28s → 1.91s 6/16 死 2.97s → 2.30s 16/16 死 >60s 未返回 → 2.37s 新增 tests/test_failover.py(7 项,含熔断期不再握手)与 scripts/bench_failover.py(对比压测)。 * chore(release): 0.7.2 - server_time 解码修正(0.7.1 及之前按「小时 + 百万分之一小时」解析是错的) - 服务器中途掉线的四项隔离机制(锁外建连 / 本轮不重试 / 池级熔断 / 批次回队) - 版本号四处对齐:pyproject.toml、__init__.py、uv.lock、CHANGELOG --------- Co-authored-by: openbot-coder <openbot-coder@users.noreply.github.com>
69 lines
2.0 KiB
TOML
69 lines
2.0 KiB
TOML
[project]
|
|
name = "pytdxdata"
|
|
version = "0.7.2"
|
|
description = "通达信(TongDaXin)行情数据客户端:动态连接池 + 双层TTL缓存 + 3连接并发分页,纯asyncio零运行时依赖,支持A股/港股/美股/期货/期权"
|
|
readme = "README.md"
|
|
requires-python = ">=3.11"
|
|
license = "MIT"
|
|
license-files = ["LICENSE"]
|
|
keywords = ["tdx", "trading", "stock", "kline", "quote", "通达信", "A股", "港股", "美股", "期货", "asyncio", "quant"]
|
|
authors = [
|
|
{ name = "openbot-coder", email = "openbot-coder@users.noreply.github.com" }
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 4 - Beta",
|
|
"Intended Audience :: Developers",
|
|
"Intended Audience :: Financial and Insurance Industry",
|
|
"Topic :: Office/Business :: Financial :: Investment",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
"Operating System :: OS Independent",
|
|
"Framework :: AsyncIO",
|
|
"Typing :: Typed",
|
|
]
|
|
dependencies = []
|
|
|
|
[project.urls]
|
|
Homepage = "https://github.com/openbot-coder/pytdxdata"
|
|
Repository = "https://github.com/openbot-coder/pytdxdata"
|
|
Documentation = "https://openbot-coder.github.io/pytdxdata/"
|
|
|
|
[project.optional-dependencies]
|
|
uvloop = ["uvloop>=0.21"]
|
|
pandas = ["pandas>=2.0"]
|
|
polars = ["polars>=1.0"]
|
|
dataframe = ["pandas>=2.0", "polars>=1.0"]
|
|
dev = ["pytest>=8.0", "pytest-asyncio>=0.24", "ruff>=0.6"]
|
|
|
|
[project.scripts]
|
|
tdx = "pytdxdata.cli:main"
|
|
|
|
[build-system]
|
|
requires = ["uv_build>=0.11.1,<0.12.0"]
|
|
build-backend = "uv_build"
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py313"
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|
|
testpaths = ["tests"]
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"pytest>=9.1.1",
|
|
"pytest-asyncio>=1.4.0",
|
|
# DataFrame 后端的双实现都要在本地/CI 里被真实覆盖,不能只在 extras 里声明
|
|
"pandas>=2.0",
|
|
"polars>=1.0",
|
|
]
|
|
docs = [
|
|
"mkdocs-material>=9.5",
|
|
"mkdocstrings[python]>=0.26",
|
|
"ruff>=0.6",
|
|
"jieba>=0.42",
|
|
]
|
|
|