Skip to content

Async read query #340

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

Closed
varna9000 opened this issue Oct 1, 2021 · 1 comment
Closed

Async read query #340

varna9000 opened this issue Oct 1, 2021 · 1 comment
Labels
wontfix This will not be worked on
Milestone

Comments

@varna9000
Copy link

varna9000 commented Oct 1, 2021

Hi can you prove an example how to make async read query?

This works well writing data but I can't implement it for reading. I use this function:

async def read_record():
    reader = client.query_api()
    q='from(bucket:"my-bucket") |> range(start: -30m)'
    return asyncio.get_running_loop().run_in_executor(None, reader.query(q))

and I'm calling it with

result= await read_record()

however I get ValueError: [RuntimeError("await wasn't used with future"), TypeError('vars() argument must have __dict__ attribute')]

@varna9000
Copy link
Author

Got it working with the following change to the function:

async def read_record():
    reader = client.query_api()
    q='from(bucket:"my-bucket") |> range(start: -30m)'
    return await asyncio.get_running_loop().run_in_executor(None, partial(reader.query, query=q))

@bednar bednar closed this as completed Oct 4, 2021
@bednar bednar added the wontfix This will not be worked on label Oct 4, 2021
@bednar bednar added this to the 1.22.0 milestone Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants