Basic Async Actor Call (#6183)

* Start trying to figure out where to put fibers

* Pass is_async flag from python to context

* Just running things in fiber works

* Yield implemented, need some debugging to make it work

* It worked!

* Remove debug prints

* Lint

* Revert the clang-format

* Remove unnecessary log

* Remove unncessary import

* Add attribution

* Address comment

* Add test

* Missed a merge conflict

* Make test pass and compile

* Address comment

* Rename async -> asyncio

* Move async test to py3 only

* Fix ignore path
This commit is contained in:
Simon Mo
2019-11-21 11:56:46 -08:00
committed by GitHub
parent c4132b501b
commit 29ba6bfc64
20 changed files with 242 additions and 28 deletions
+11 -2
View File
@@ -358,7 +358,8 @@ class ActorClass(object):
is_direct_call=None,
max_concurrency=None,
name=None,
detached=False):
detached=False,
is_asyncio=False):
"""Create an actor.
This method allows more flexibility than the remote method because
@@ -381,6 +382,8 @@ class ActorClass(object):
name: The globally unique name for the actor.
detached: Whether the actor should be kept alive after driver
exits.
is_asyncio: Turn on async actor calls. This only works with direct
actor calls.
Returns:
A handle to the newly created actor.
@@ -400,6 +403,12 @@ class ActorClass(object):
if max_concurrency < 1:
raise ValueError("max_concurrency must be >= 1")
if is_asyncio and not is_direct_call:
raise ValueError(
"Setting is_asyncio requires is_direct_call=True.")
if is_asyncio and max_concurrency != 1:
raise ValueError("Setting is_asyncio requires max_concurrency=1.")
worker = ray.worker.get_global_worker()
if worker.mode is None:
raise Exception("Actors cannot be created before ray.init() "
@@ -487,7 +496,7 @@ class ActorClass(object):
function_descriptor.get_function_descriptor_list(),
creation_args, meta.max_reconstructions, resources,
actor_placement_resources, is_direct_call, max_concurrency,
detached)
detached, is_asyncio)
actor_handle = ActorHandle(
actor_id,