Last active
July 14, 2020 23:50
-
-
Save stephanie-wang/c635a3df967df75ed4acc0cc5e75aed5 to your computer and use it in GitHub Desktop.
Detached job
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ray | |
from ray.test_utils import SignalActor | |
@ray.remote | |
class Driver: | |
def __init__(self): | |
pass | |
def start(self, signal): | |
signal.send.remote() | |
# Driver code here. Any spawned tasks/actors will be owned by this actor | |
# so they will not get cleaned up until this actor is dead. | |
# ... | |
ray.init() | |
driver = Driver.options(name="my_job").remote() # Detached actor. | |
s = SignalActor.remote() | |
driver.start.remote(s) | |
ray.get(s.wait.remote()) # Wait for the `Driver.start` task to begin before exiting. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We could make this a utility too, e.g.,