From 4dd41844d0eb4ed8a49df78479484f0ed2e79b42 Mon Sep 17 00:00:00 2001 From: Simon Mo Date: Wed, 22 Jan 2020 16:05:34 -0800 Subject: [PATCH] Ignore blocking ray.wait if timeout is zero (#6891) --- python/ray/tests/py3_test.py | 6 ++++++ python/ray/worker.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/python/ray/tests/py3_test.py b/python/ray/tests/py3_test.py index 184521398..02700057c 100644 --- a/python/ray/tests/py3_test.py +++ b/python/ray/tests/py3_test.py @@ -254,10 +254,16 @@ def test_asyncio_actor_async_get(ray_start_regular_shared): def remote_task(): return 1 + plasma_object = ray.put(2) + @ray.remote class AsyncGetter: async def get(self): return await remote_task.remote() + async def plasma_get(self): + return await plasma_object + getter = AsyncGetter.options(is_asyncio=True).remote() assert ray.get(getter.get.remote()) == 1 + assert ray.get(getter.plasma_get.remote()) == 2 diff --git a/python/ray/worker.py b/python/ray/worker.py index 376adc693..e292fb1f9 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -1573,9 +1573,9 @@ def wait(object_ids, num_returns=1, timeout=None): """ worker = global_worker - if hasattr( - worker, - "core_worker") and worker.core_worker.current_actor_is_asyncio(): + if hasattr(worker, + "core_worker") and worker.core_worker.current_actor_is_asyncio( + ) and timeout != 0: raise RayError("Using blocking ray.wait inside async method. " "This blocks the event loop. Please use `await` " "on object id with asyncio.wait. ")