From 14bc33210a20d70e47ff0e790c84b9f48bfa1454 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 22 Nov 2024 16:33:28 +0100 Subject: [PATCH 1/3] chore: add explanatory note to CancelledError. --- influxdb_client/client/flux_csv_parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/influxdb_client/client/flux_csv_parser.py b/influxdb_client/client/flux_csv_parser.py index 7a73e3f8..65ba5a04 100644 --- a/influxdb_client/client/flux_csv_parser.py +++ b/influxdb_client/client/flux_csv_parser.py @@ -1,6 +1,6 @@ """Parsing response from InfluxDB to FluxStructures or DataFrame.""" - +import asyncio import base64 import codecs import csv as csv_parser @@ -147,6 +147,9 @@ async def _parse_flux_response_async(self): df = self._prepare_data_frame() if not self._is_profiler_table(metadata.table): yield df + except (asyncio.exceptions.CancelledError, asyncio.TimeoutError) as ce: + ce.add_note("Stream cancelled during read. Recommended: Check Influxdb client `timeout` setting.") + raise finally: self._close() From d5714cf5fa9c2eb0d32a85bca62cd07483931e41 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Mon, 25 Nov 2024 11:08:46 +0100 Subject: [PATCH 2/3] docs: update CHANGELOG.md and README.md --- CHANGELOG.md | 4 ++++ README.md | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e0c837..35a88ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## 1.48.0 [unreleased] +### Bug Fixes + +1. [#679](https://github.com/influxdata/influxdb-client-python/pull/679): Add note to caught errors about need to check client timeout. + ## 1.47.0 [2024-10-22] ### Bug Fixes diff --git a/README.md b/README.md index ef4eff86..5b541dcf 100644 --- a/README.md +++ b/README.md @@ -1313,6 +1313,13 @@ All async APIs are available via `influxdb_client.client.influxdb_client_async.I and also check to readiness of the InfluxDB via `/ping` endpoint: +The `InfluxDBClientAsync` constructor accepts a number of __configuration properties__. Most useful among these are: + +* `connection_pool_maxsize` - The total number of simultaneous connections. Defaults to `multiprocessing.cpu_count() * 5`. +* `enable_gzip` - enable gzip compression during `write` and `query` calls. Defaults to `false`. +* `proxy` - URL of an HTTP proxy to be used. +* `timeout` - The maximum number of milliseconds for handling HTTP requests from initial handshake to handling response data. This is passed directly to the underlying transport library. If large amounts of data are anticipated, for example from `query_api.query_stream(...)`, this should be increased to avoid `TimeoutError` or `CancelledError`. Defaults to 10_000 ms. + > ``` python > import asyncio > From 36888b05c12aecc85505c2749507d7346628f1f1 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Mon, 25 Nov 2024 13:59:49 +0100 Subject: [PATCH 3/3] chore: remove import of asyncio in non-async API --- influxdb_client/client/flux_csv_parser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/influxdb_client/client/flux_csv_parser.py b/influxdb_client/client/flux_csv_parser.py index 65ba5a04..99e68094 100644 --- a/influxdb_client/client/flux_csv_parser.py +++ b/influxdb_client/client/flux_csv_parser.py @@ -1,6 +1,5 @@ """Parsing response from InfluxDB to FluxStructures or DataFrame.""" -import asyncio import base64 import codecs import csv as csv_parser @@ -147,8 +146,10 @@ async def _parse_flux_response_async(self): df = self._prepare_data_frame() if not self._is_profiler_table(metadata.table): yield df - except (asyncio.exceptions.CancelledError, asyncio.TimeoutError) as ce: - ce.add_note("Stream cancelled during read. Recommended: Check Influxdb client `timeout` setting.") + except BaseException as e: + e_type = type(e).__name__ + if "CancelledError" in e_type or "TimeoutError" in e_type: + e.add_note("Stream cancelled during read. Recommended: Check Influxdb client `timeout` setting.") raise finally: self._close()