ray.runtime_context.RuntimeContext.task_id#

property RuntimeContext.task_id#

Get current task ID for this worker.

Task ID is the id of a Ray task. This shouldn’t be used in a driver process.

Example

import ray

@ray.remote
class Actor:
    def ready(self):
        return True

@ray.remote
def f():
    return True

# All the below code generates different task ids.
# Task ids are available for actor creation.
a = Actor.remote()
# Task ids are available for actor tasks.
a.ready.remote()
# Task ids are available for normal tasks.
f.remote()
Returns:

The current worker’s task id. None if there’s no task id.

Warning

DEPRECATED: This API is deprecated and may be removed in future Ray releases. Use get_task_id() instead