Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
1. [#732](https://github.com/influxdata/influxdb-client-python/pull/732): Apply the `#default` annotation in `FluxCsvParser` when it comes before `#datatype`.
1. [#733](https://github.com/influxdata/influxdb-client-python/pull/733): Write the last batch when the batching `WriteApi` is closed in an `atexit` handler instead of dropping it with "cannot schedule new futures after interpreter shutdown".
1. [#734](https://github.com/influxdata/influxdb-client-python/pull/734): Match `data_frame_timestamp_column` by exact column name, so a field whose name is part of the timestamp column name (e.g. `Open` with `OpenTime`) is no longer dropped.
1. [#739](https://github.com/influxdata/influxdb-client-python/pull/739): Async CSV query cancellation no longer raises `AttributeError` with pre 3.11 release Python platforms.

## 1.50.0 [2026-01-23]

Expand Down
2 changes: 1 addition & 1 deletion influxdb_client/client/flux_csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def _parse_flux_response_async(self):
yield df
except BaseException as e:
e_type = type(e).__name__
if "CancelledError" in e_type or "TimeoutError" in e_type:
if ("CancelledError" in e_type or "TimeoutError" in e_type) and hasattr(e, "add_note"):
e.add_note("Stream cancelled during read. Recommended: Check Influxdb client `timeout` setting.")
raise
finally:
Expand Down
32 changes: 32 additions & 0 deletions tests/test_FluxCSVParserAsyncExceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import asyncio
import unittest
from unittest.mock import Mock

from influxdb_client.client.flux_csv_parser import FluxCsvParser, FluxSerializationMode


class FluxCsvParserAsyncExceptionTest(unittest.TestCase):
def test_preserves_exception_and_closes_response(self):
async def check(error):
response = Mock()
parser = FluxCsvParser(response, FluxSerializationMode.stream)

async def rows():
raise error
yield # Make this an async iterator, like the CSV reader.

parser._reader = rows()
with self.assertRaises(type(error)) as raised:
await parser.generator_async().__anext__()
self.assertIs(raised.exception, error)
response.close.assert_called_once()
if hasattr(error, "add_note") and isinstance(error, (asyncio.CancelledError, asyncio.TimeoutError)):
self.assertTrue(any("timeout" in note for note in error.__notes__))

loop = asyncio.new_event_loop()
try:
for error in (asyncio.CancelledError(), asyncio.TimeoutError(), ValueError("invalid row")):
with self.subTest(error=type(error).__name__):
loop.run_until_complete(check(error))
finally:
loop.close()
Loading