Bound the number of simultaneous requests and preserve a record ID with each reply. A semaphore restricts how many background HTTP calls are in flight.
Example
import asyncio
from ngila import NgilaClient
client = NgilaClient()
gate = asyncio.Semaphore(4)
async def classify(record, questions):
async with gate:
reply = await client.system_one_async(record["text"], questions)
return record["id"], reply["answers"]