# Executors


# Functions

top-level functions:                                                                                                                                                       

prefect.utilities.executors.run_task_with_timeout

(task, args=(), kwargs=None, logger=None)[source]

Helper function for implementing timeouts on task executions.

The exact implementation varies depending on whether this function is being run in the main thread or a non-daemonic subprocess. If this is run from a daemonic subprocess or on Windows, the task is run in a ThreadPoolExecutor and only a soft timeout is enforced, meaning a TaskTimeoutSignal is raised at the appropriate time but the task continues running in the background.

The task is passed instead of a function so we can give better logs and messages. If you need to run generic functions with timeout handlers, run_with_thread_timeout or run_with_multiprocess_timeout can be called directly

Args:

  • task (Task): the task to execute task.timeout specifies the number of seconds to allow task.run to run for before terminating
  • args (Sequence): arguments to pass to the function
  • kwargs (Mapping): keyword arguments to pass to the function
  • logger (Logger): an optional logger to use. If not passed, a logger for the prefect.run_task_with_timeout_handler namespace will be created.
Returns:
  • the result of f(*args, **kwargs)
Raises:
  • TaskTimeoutSignal: if function execution exceeds the allowed timeout

This documentation was auto-generated from commit ffa9a6c
on February 1, 2023 at 18:44 UTC