Temporal with synchronous python services

Currently our stack is based of python micro-services, which do not use async-io. We would like to use temporal for some of our workloads, but are facing an issue when the activities call our existing microservices. We deploy the worker inside a GRPC server (python service). But when an async activity makes an I/O bound call, in this case a grpc call to another service, this becomes a blocking call and other activities are blocked. Our understanding is that in Python, the I/O bound calls will relinquish the thread, but we do not see this behavior when a temporal activity makes a I/O bound call. This means in a worker, only 1 activity can run at the same time which defeats the purpose of using Temporal. Could we get some guidance on how we can solve this specifically with Python services setup which do not use asyncio?

You should not use async def activities, you should just use normal def activities which are in their own thread and can block normally. You’ll need to provide a ThreadPoolExecutor to the activity. See this doc, this doc, and this sample.

1 Like