-
Notifications
You must be signed in to change notification settings - Fork 1.7k
BigQuery: make jobs awaitable #15742
Copy link
Copy link
Open
Labels
Python 3 OnlyThis work would involve supporting Python 3 only code paths.This work would involve supporting Python 3 only code paths.api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Metadata
Metadata
Assignees
Labels
Python 3 OnlyThis work would involve supporting Python 3 only code paths.This work would involve supporting Python 3 only code paths.api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
I know BigQuery jobs are asynchronous by default. However, I am struggling to make my datapipeline async end-to-end.
Looking at this JS example, I thought it would be the most Pythonic to make a BigQuery job awaitable. However, I can't get that to work in Python i.e. errors when
await client.query(query). Looking at the source code, I don't see which method returns an awaitable object.I have little experience in writing async Python code and found this example that wraps jobs in a
async def coroutine.The
google.api_core.operation.Operationshows how to useadd_done_callbackto asynchronously wait for long-running operations. I have tried that, but the following yieldsAttributeError: 'QueryJob' object has no attribute '_condition':Given that jobs are already asynchronous, would it make sense to add a method that returns an awaitable?
Or am I missing something and is there an Pythonic way to use the BigQuery client with the async/await pattern?