Fix exit_actor in asyncio mode (#12693)

This commit is contained in:
Simon Mo
2020-12-11 09:35:17 -08:00
committed by GitHub
parent 699ded5328
commit 68d7fa2137
3 changed files with 49 additions and 0 deletions
+9
View File
@@ -1,6 +1,7 @@
import inspect
import logging
import weakref
import _thread
import ray.ray_constants as ray_constants
import ray._raylet
@@ -1018,6 +1019,14 @@ def exit_actor():
ray.disconnect()
# Disconnect global state from GCS.
ray.state.state.disconnect()
# In asyncio actor mode, we can't raise SystemExit because it will just
# quit the asycnio event loop thread, not the main thread. Instead, we
# raise an interrupt signal to the main thread to tell it to exit.
if worker.core_worker.current_actor_is_asyncio():
_thread.interrupt_main()
return
# Set a flag to indicate this is an intentional actor exit. This
# reduces log verbosity.
exit = SystemExit(0)