mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 18:44:07 +08:00
Add more user-friendly error message upon async def remote task (#13915)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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__]))
|
||||
|
||||
Reference in New Issue
Block a user