class_docstr: A class used for getting runtime context.
docstr: Get current task ID for this worker or driver.
  
  Task ID is the id of a Ray task.
  This shouldn't be used in a driver process.
  
  Example:
  
      .. testcode::
  
          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.
docstr_tok: ["Get","current","task","ID","for","this","worker","or","driver",".","Task","ID","is","the","id","of","a","Ray","task",".","This","should","n't","be","used","in","a","driver","process",".","Example",":","..","testcode",":",":","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","."]
code: def task_id(self):
      """Get current task ID for this worker or driver.
  
      Task ID is the id of a Ray task.
      This shouldn't be used in a driver process.
  
      Example:
  
          .. testcode::
  
              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.
      """
      # only worker mode has actor_id
      assert (
          self.worker.mode == ray._private.worker.WORKER_MODE
      ), f"This method is only available when the process is a\
                   worker. Current mode: {self.worker.mode}"
  
      task_id = self._get_current_task_id()
      return task_id if not task_id.is_nil() else None
  
imports: import logging
  from typing import Any, Dict, List, Optional
  import ray._private.worker
  from ray._private.client_mode_hook import client_mode_hook
  from ray._private.utils import pasre_pg_formatted_resources_to_original
  from ray._raylet import TaskID
  from ray.runtime_env import RuntimeEnv
  from ray.util.annotations import Deprecated, PublicAPI
label_desc: Use image node_id 8 for calling the RuntimeContext obj's underlying member method code with example usage: obj.task_id() and returns: unknown