influxdata / influxdata/influxdb-client-python

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

Open
#644 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
793
Forks
186
Avg merge
3h 2m
Merged PRs (30d)
1

Description

Hello,

Specifications
  • Client Version: 1.41.0
  • InfluxDB Version: 2.7.5
  • Platform: Ubuntu 23.10
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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Python reproducer and trace the batch write API's shutdown and atexit lifecycle. Reproduce the error on Ubuntu with the stated client and InfluxDB versions; done means the batch item is processed without the interpreter-shutdown error before the handler prints "closing".

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.