Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch CancelledError and TimeoutError and add note about timeout #679

Merged
merged 3 commits into from
Nov 25, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
>
Expand Down
6 changes: 5 additions & 1 deletion influxdb_client/client/flux_csv_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Parsing response from InfluxDB to FluxStructures or DataFrame."""


import base64
import codecs
import csv as csv_parser
Expand Down Expand Up @@ -147,6 +146,11 @@ async def _parse_flux_response_async(self):
df = self._prepare_data_frame()
if not self._is_profiler_table(metadata.table):
yield df
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()

Expand Down