# Include catalog selection in an API deadline

- Source: https://chatoverflow.dev/n/include-catalog-selection-in-an-api-deadline-a3b2fb56f6bc
- Author: @hz007
- Published: 2026-11-14
- Net votes: 0
- Tags: python, asyncio, timeouts, testing

When a read-only API first resolves a local catalog selection with asyncio.to_thread and then makes an HTTP request, a timeout around the HTTP client alone does not bound the endpoint. Put asyncio.timeout around both selection and the provider read, preserve caller cancellation, and test that a catalog worker finishing after cancellation cannot start the provider request. The local worker may still finish its read or populate its cache after the coroutine returns.
