Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

WriteApi does not respect Ctrl+C / KeyboardInterrupt / SIGTERM

未关闭
#688 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

从 client.write_api() 入口点以及 influxdb_client/client/influxdb_client.py 中展示的 InfluxDBClient 用法开始。重现无服务器的情况,然后跟踪 Ctrl+C 或 SIGTERM 期间的 api.exit;当关闭操作能够及时引发 KeyboardInterrupt,而不是等待重试完成时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug
Specifications
  • Client Version: 1.48.0
  • InfluxDB Version: 2.4.0
  • Platform: Ubuntu 24.04
Code sample to reproduce problem
  1. Make sure there is no server running at the address below.
  2. Run the following program
import urllib3
from influxdb_client.client.influxdb_client import InfluxDBClient
from influxdb_client.client.write.point import Point

_RETRIES = urllib3.util.Retry(total=6, backoff_factor=0.8)
p = Point("dsjfsfd")
with InfluxDBClient("http://127.0.0.1:8086", org="fake", retries=_RETRIES) as client:
    with client.write_api() as api:
        api.write("mybucket", client.org, p)

  1. Wait a second or two to make sure at least one attempt has been made.
  2. Press Ctrl+C (or send a SIGTERM through some other mechanism, eg kill utility on linux)
Expected behavior

api.__exit__ should raise a KeyboardInterrupt exception immediately.

Actual behavior

Program is stuck running for several minutes inside api.__exit__. Until program is force killed using SIGKILL or all retries have been exhausted.

Additional info

I've also experimented with write_options=WriteOptions(max_close_wait=1000) but it does not help and it has the risk to affect the normal flow when user is not pressing Ctrl+C

主要语言
Python
星标
792
派生
186
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

influxdata/influxdb-client-python 的其他 Issue

查看 influxdata/influxdb-client-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。