def determine_workers(
    workers: Union[bool, int],
    rows_total: Optional[int] = None,
) -> Union[bool, int]:
    """Determine the number of workers to use for distributed processing."""
    if rows_total is not None and rows_total <= 1:
        # Disable distributed processing if there is no rows or only one row.
        return False
    if (
        workers is False
        and os.environ.get("DATACHAIN_DISTRIBUTED")
        and os.environ.get("DATACHAIN_SETTINGS_WORKERS")
    ):
        # Enable distributed processing by default if the module is available,
        # and a default number of workers is provided.
        workers = int(os.environ["DATACHAIN_SETTINGS_WORKERS"])
    if not workers or workers <= 0:
        return False
    return workers
Determine the number of workers to use for distributed processing.
src/datachain/utils.py