get_dataset_linked_dashboard_count is async (coroutine function), but was passed to asyncio.to_thread() which expects a sync callable. This returned a coroutine object instead of an int, causing: '>' not supported between instances of 'coroutine' and 'int' Fix: await the async method directly inside asyncio.wait_for().