From 03df0b080592312ccdcc4210dca452bb10286c2c Mon Sep 17 00:00:00 2001 From: Hongchao Deng Date: Tue, 9 Jul 2024 12:59:05 -0700 Subject: [PATCH] [core] catch exception in async_callback (#46488) Signed-off-by: hongchaodeng --- python/ray/_raylet.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/ray/_raylet.pyx b/python/ray/_raylet.pyx index 7783d9cc38a5..ccddfbe4f4ed 100644 --- a/python/ray/_raylet.pyx +++ b/python/ray/_raylet.pyx @@ -5154,6 +5154,10 @@ cdef void async_callback(shared_ptr[CRayObject] obj, user_callback = user_callback_ptr user_callback(result) + except Exception: + # Only log the error here because this calllback is called from Cpp + # and Cython will ignore the exception anyway + logger.exception(f"failed to run async callback (user func)") finally: # NOTE: we manually increment the Python reference count of the callback when # registering it in the core worker, so we must decrement here to avoid a leak.