Skip to content

Problem with multiple ray.init and ray.shutdown #4192

@raulchen

Description

@raulchen
import ray

@ray.remote
def f():
    return 1

ray.init(num_cpus=1)
print(ray.get(f.remote()))
ray.shutdown()

ray.init(num_cpus=1)
print(ray.get(f.remote()))
ray.shutdown()

The above script will hang at the second ray.get(f.remote()) with error message This worker was asked to execute a function that it does not have registered. You may have to restart Ray. This is because the function is only registered to the first GCS.

I discovered this issue when I was trying to consolidating python tests in travis, see

ray/.travis.yml

Lines 182 to 184 in 387c98c

# TODO(williamma12): We cannot use pytests built-in test discovery because
# it causes a lot of the tests to fail on travis' apple builds even though
# it runs without issue on an apple build locally.
cc @williamma12

Similar but not the same with #3897

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions