Add more user-friendly error message upon async def remote task (#13915)

This commit is contained in:
Kathryn Zhou
2021-02-04 21:33:33 -05:00
committed by GitHub
parent e89bbcbd44
commit 982c606b86
3 changed files with 42 additions and 0 deletions
+6
View File
@@ -477,6 +477,12 @@ cdef execute_task(
if debugger_breakpoint != b"":
ray.util.pdb.set_trace(
breakpoint_uuid=debugger_breakpoint)
if inspect.iscoroutinefunction(function_executor):
raise ValueError(
"'async def' should not be used for remote "
"tasks. You can wrap the async function with "
"`asyncio.get_event_loop.run_until(f())`. "
"See more at docs.ray.io/async_api.html")
outputs = function_executor(*args, **kwargs)
next_breakpoint = (
ray.worker.global_worker.debugger_breakpoint)
+11
View File
@@ -244,6 +244,17 @@ def test_async_callback(ray_start_regular_shared):
wait_for_condition(lambda: "completed-2" in global_set)
def test_async_function_errored(ray_start_regular_shared):
@ray.remote
async def f():
pass
ref = f.remote()
with pytest.raises(ValueError):
ray.get(ref)
if __name__ == "__main__":
import pytest
sys.exit(pytest.main(["-v", __file__]))