async def my_rpc(self, request, context)
...
...
...
stream: AsyncIterable[Response2] = self.runner.get_stream()
res = list()
try:
loop = asyncio.get_running_loop()
with ProcessPoolExecutor() as executor:
async for msg in stream:
print(msg)
if msg.success:
stuff = await loop.run_in_executor(executor, my_cpu_bound_func, msg.data)
....
...
...
except Exception as e:
print(e)
This fails with too_many_pings error and the server side closes the connection. But if i take out asyncio.get_running_loop() and consequently run_in_executor() and just do the work there like a normal function call, it works.