Seem to find a solution.
asyncio.create_task
is made for running coroutine in the same event loop as the main process. And await create_task(CatalogHandler.catalog_check(user.group_name, req.source, req.csv))
blocks process because it makes event loop wait for function execution.
What I changed:
CatalogHandler.catalog_check
method sync.await to_thread(CatalogHandler.catalog_check, user.group_name, req.source, req.csv)
. It makes function run in a separate thread without blocking main event loop.And everything seems to work! Now I can execute a long-running process with websockets without blocking other API endpoints. Hope this is being useful. Will update this answer if I find anything interesting about the solution.