Image generated by [ChatGPT](https://chatgpt.com/)

SystemExit Hangs asyncio.run_coroutine_threadsafe

Today, while debugging an issue with Ray, I encountered a problem because I did not notice the special behavior of Python’s asyncio.run_coroutine_threadsafe. The official documentation does not explicitly mention it; you have to look at the CPython source code to understand what is happening, which led to a long debugging session. I am documenting this issue here. According to the official documentation , this function is used to run a coroutine in an event loop on another thread, and it returns a Future object. ...

Posted on: 2025-03-05 · Edited on: 2025-03-18 · Chi-Sheng Liu