ThreadPoolExecutor alway alive after close batching API and database client
还没有人认领这个 Issue。
评估
调研方向
首先跟踪使用 WriteOptions 和 WriteType.batching 的 InfluxDBClient.write_api(),然后继续跟踪 ThreadPoolExecutor 的 close() 和 flush() 路径。使用提供的脚本重现该问题;在关闭 batching API 和客户端后,executor thread 不再列出即表示完成。
由索引模型根据 Issue 内容生成。
描述
Specifications
- Client Version: 1.40.0
- InfluxDB Version: 2.7.1
- Platform: Ubuntu
- Python Version: 3.10.9
Code sample to reproduce problem
import threading
import time
from influxdb_client import (
InfluxDBClient
)
from influxdb_client.client.write_api import (
WriteOptions,
WriteType,
)
def check_thread_alive():
"""Check if all thread are correctly closed."""
msg: str = f"{len(threading.enumerate())} threads running"
for thread in threading.enumerate():
msg += f"\n > {thread.name}"
print(msg)
data_points = [
{
"measurement": "temperature",
"tags": {"location": "room1"},
"time": "2024-02-02T12:00:00Z",
"fields": {"value": 25.5}
},
{
"measurement": "humidity",
"tags": {"location": "room1"},
"time": "2024-02-02T12:00:00Z",
"fields": {"value": 60}
},
]
print(">>>>>> START")
check_thread_alive()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> create InfluxDBClient")
client = InfluxDBClient(
url="localhost:8086",
org="test",
token="LLxHucOTfD1zSHVSadNRJRzZh_nNZGNf1KrHCieOj847ucB2RcLCBJZogP2zNtMxvAZMlAWsSOHgSJChaO7b3A==")
check_thread_alive()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> create write_api")
batch_write_api = client.write_api(
write_options=WriteOptions(
write_type=WriteType.batching))
check_thread_alive()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> close write_api")
batch_write_api.close()
batch_write_api.flush()
check_thread_alive()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> close InfluxDBClient")
client.close()
check_thread_alive()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wait 5 s")
time.sleep(5)
check_thread_alive()
print(">>>>>> STOP")
Expected behavior
When we close the batching API, associated threads are closed
Actual behavior
When we close the batching API, the associated thread ThreadPoolExecutor is alway alive
Additional info
My output
>>>>>> START
1 threads running
> MainThread
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> create InfluxDBClient
1 threads running
> MainThread
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> create write_api
2 threads running
> MainThread
> ThreadPoolExecutor-1_0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> close write_api
2 threads running
> MainThread
> ThreadPoolExecutor-1_0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> close InfluxDBClient
2 threads running
> MainThread
> ThreadPoolExecutor-1_0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wait 5 s
2 threads running
> MainThread
> ThreadPoolExecutor-1_0
>>>>>> STOP
- 主要语言
- Python
- 星标
- 792
- 派生
- 186
- 平均合并
- 3 小时 2 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
influxdata/influxdb-client-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
influxdata/influxdb-client-python#613 · 7 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 65/100
-
难度 3/5 1-2 天 新手友好度 45/100
influxdata/influxdb-client-python#694 · 6 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 30/100
influxdata/influxdb-client-python#693 · 2 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
查看 influxdata/influxdb-client-python 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100