influxdata / influxdata/influxdb-client-python
ThreadPoolExecutor alway alive after close batching API and database client
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 793
- Forks
- 186
- Ø Merge
- 3 Std. 2 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, InfluxDBClient.write_api() mit WriteOptions und WriteType.batching nachzuverfolgen, und folge anschließend den close()- und flush()-Pfaden für den ThreadPoolExecutor. Reproduziere das Problem mit dem bereitgestellten Skript; fertig ist die Aufgabe, wenn der Executor-Thread nach dem Schließen der batching API und des Clients nicht mehr aufgelistet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100