Skip to content

Exception with async queries when using profiler #496

@tlebrize

Description

@tlebrize

Specifications

  • Client Version: pypi1.32.0
  • InfluxDB Version: docker influxdb:2.2-alpine
  • Platform: python3.10.6 on Ubuntu 22.04

Code sample to reproduce problem

from influxdb_client.client.query_api import QueryOptions
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync
import asyncio

async def main():
    client = InfluxDBClientAsync(
        url=INFLUX_SERVER,
        token=INFLUX_TOKEN,
        org=INFLUX_ORG,
        verify_ssl=False,
    )

    def callback(records):
        print(records.values)

    api = client.query_api(
        QueryOptions(
            profilers=["operator", "query"],
            profiler_callback=callback,
        )
    )

    flux = """
    import "json"

    from(bucket: "my_bucket")
        |> range(start: -1y)
        |> keep(columns: ["_time"])
        |> limit(n: 1)
    """

    async for line in await api.query_stream(flux):
        print(line)


if __name__ == "__main__":
    asyncio.run(main())

Expected behavior

Be able to use the query records and the profiling information without triggering an exception.

Actual behavior

Records and profiling information were printed to stdout then the client raised:

Traceback (most recent call last):
  File "/tmp/minimal-influx-bug/bug.py", line 44, in <module>
    asyncio.run(main())
  File "/home/tim/.pyenv/versions/3.10.6/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/tim/.pyenv/versions/3.10.6/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/tmp/minimal-influx-bug/bug.py", line 39, in main
    async for line in await api.query_stream(flux):
  File "/home/tim/.pyenv/versions/newbackend-poc/lib/python3.10/site-packages/influxdb_client/client/flux_csv_parser.py", line 140, in _parse_flux_response_async
    for val in self._parse_flux_response_row(metadata, csv[0]):
  File "/home/tim/.pyenv/versions/newbackend-poc/lib/python3.10/site-packages/influxdb_client/client/flux_csv_parser.py", line 228, in _parse_flux_response_row
    flux_record = self.parse_record(metadata.table_index - 1, metadata.table, csv)
  File "/home/tim/.pyenv/versions/newbackend-poc/lib/python3.10/site-packages/influxdb_client/client/flux_csv_parser.py", line 264, in parse_record
    str_val = csv[fluxColumn.index + 1]
IndexError: list index out of range

Additional info

The sync client seems to be working fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy