Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

ThreadPoolExecutor alway alive after close batching API and database client

Abierto
#640 3 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
databases

Línea de trabajo

Comienza siguiendo InfluxDBClient.write_api() con WriteOptions y WriteType.batching, y después sigue las rutas de close() y flush() para ThreadPoolExecutor. Reproduce el problema con el script proporcionado; se considera terminado cuando el hilo del executor ya no aparece en la lista después de cerrar la batching API y el cliente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
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
Lenguaje dominante
Python
Estrellas
792
Forks
186
Merge medio
3 h 2 min
PR fusionados (30 d)
1

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de influxdata/influxdb-client-python

Todos los issues de influxdata/influxdb-client-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.