Skip to content

[core] ray cancel doesn't cancel sleeping tasks when not forced  #32954

@rickyyx

Description

@rickyyx

What happened + What you expected to happen

If a task is sleeping, ray.cancel on the task doesn't cancel the task.

Also, the documentation at https://docs.ray.io/en/latest/ray-core/api/doc/ray.cancel.html#ray.cancel could be improved on the force=False description, i.e. what will get canceled when not forced, rather than on implementation details.

Versions / Dependencies

NA

Reproduction script

import ray
import time


@ray.remote
def sleep():
    time.sleep(999)


t = sleep.remote()

# Make sure the task `sleep` gets running on the worker. 
time.sleep(3)
ray.cancel(t)

ray.get(t) # Should raise task cancelled errors. 

Issue Severity

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issue, but not time-criticalcoreIssues that should be addressed in Ray Corecore-apidocsAn issue or change related to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions