influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
713 stars 187 forks source link

atexit doesn’t work properly in batch mode: "cannot schedule new futures after interpreter shutdown" #644

Open bfontaine opened 7 months ago

bfontaine commented 7 months ago

Hello,

Specifications

Code sample to reproduce problem

import atexit
from influxdb_client import InfluxDBClient, Point

influxdb = InfluxDBClient(url="...", token="...", org="...")

write_api = influxdb.write_api()

@atexit.register
def close():
    print("closing")
    write_api.close()
    influxdb.close()

write_api.write("<bucket>", record=Point("test_bf").field("test", 1))

Expected behavior

Expected output:

closing

Actual behavior

Actual output:

The batch item wasn't processed successfully because: cannot schedule new futures after interpreter shutdown
closing

As you can see the atexit handler is executed, but the error happens before.

Additional info

No response

rwader-swi commented 5 months ago

looks like issues aren't addressed :(

bednar commented 5 months ago

Hi @rwader-swi,

Thanks for bringing this to our attention. I appreciate you sharing your concerns with us. I have added this issue to our backlog, and we aim to address it in our next maintenance release.

We value your input as it helps us improve and ensure our software meets user needs. I'll keep you updated on our progress regarding this issue.

Best regards

bfontaine commented 2 weeks ago

FYI I can still reproduce this issue with the latest version of the client.

Client Version: 1.46.0 Python Version: 3.11.10 InfluxDB Version: 2.7.5 Platform: Ubuntu 24.04.1 LTS