Skip to content

Instantly share code, notes, and snippets.

@joshdemir
Created December 24, 2020 15:06
Show Gist options
  • Save joshdemir/d31296982a9e5eddd533dbfc4b676bfe to your computer and use it in GitHub Desktop.
Save joshdemir/d31296982a9e5eddd533dbfc4b676bfe to your computer and use it in GitHub Desktop.
Asynchronous Azure Table PointQueries in Python
import asyncio
from azure.data.tables import TableClient
client = TableClient.from_connection_string(conn_str='foo', table_name='bar')
async def run_query(partition_key, row_key):
return client.query_entity(partition_key, row_key)
async def gather_queries(partition_key, row_key_base, substitutions):
return asyncio.gather(*[run_query(partition_key, row_key % subst) for subst in substitutions])
substitutions = ['1', '2', '3', '4', '5']
partition_key = 'partition_key'
row_key_base = 'rowkey_%s'
results = asyncio.run(gather_queries(partition_key, row_key, substitutions)).result()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment