Skip to content

Commit 44dd00e

Browse files
authored
fix: catch CancelledError and TimeoutError and add note about timeout (#679)
* chore: add explanatory note to CancelledError. * docs: update CHANGELOG.md and README.md * chore: remove import of asyncio in non-async API
1 parent 012c50a commit 44dd00e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 1.48.0 [unreleased]
22

3+
### Bug Fixes
4+
5+
1. [#679](https://github.com/influxdata/influxdb-client-python/pull/679): Add note to caught errors about need to check client timeout.
6+
37
## 1.47.0 [2024-10-22]
48

59
### Bug Fixes

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,13 @@ All async APIs are available via `influxdb_client.client.influxdb_client_async.I
13131313
13141314
and also check to readiness of the InfluxDB via `/ping` endpoint:
13151315
1316+
The `InfluxDBClientAsync` constructor accepts a number of __configuration properties__. Most useful among these are:
1317+
1318+
* `connection_pool_maxsize` - The total number of simultaneous connections. Defaults to `multiprocessing.cpu_count() * 5`.
1319+
* `enable_gzip` - enable gzip compression during `write` and `query` calls. Defaults to `false`.
1320+
* `proxy` - URL of an HTTP proxy to be used.
1321+
* `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.
1322+
13161323
> ``` python
13171324
> import asyncio
13181325
>

influxdb_client/client/flux_csv_parser.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Parsing response from InfluxDB to FluxStructures or DataFrame."""
22

3-
43
import base64
54
import codecs
65
import csv as csv_parser
@@ -147,6 +146,11 @@ async def _parse_flux_response_async(self):
147146
df = self._prepare_data_frame()
148147
if not self._is_profiler_table(metadata.table):
149148
yield df
149+
except BaseException as e:
150+
e_type = type(e).__name__
151+
if "CancelledError" in e_type or "TimeoutError" in e_type:
152+
e.add_note("Stream cancelled during read. Recommended: Check Influxdb client `timeout` setting.")
153+
raise
150154
finally:
151155
self._close()
152156

0 commit comments

Comments
 (0)