Skip to content

radical.asyncflow.utils

get_next_uid

get_next_uid()

Return the next unique task ID.

Source code in doc_env/lib/python3.13/site-packages/radical/asyncflow/utils.py
 6
 7
 8
 9
10
def get_next_uid():
    """Return the next unique task ID."""
    global _global_task_counter
    _global_task_counter += 1
    return f"{_global_task_counter:06d}"

reset_uid_counter

reset_uid_counter()

Reset the counter to zero (only call when backend shuts down).

Source code in doc_env/lib/python3.13/site-packages/radical/asyncflow/utils.py
13
14
15
16
def reset_uid_counter():
    """Reset the counter to zero (only call when backend shuts down)."""
    global _global_task_counter
    _global_task_counter = 0

get_event_loop_or_raise

get_event_loop_or_raise(context_name: str = 'AsyncWorkflowEngine') -> AbstractEventLoop

Get the current running event loop or raise a helpful error.

Parameters:

Name Type Description Default
context_name str

Name of the class/context for error messages

'AsyncWorkflowEngine'

Returns:

Type Description
AbstractEventLoop

asyncio.AbstractEventLoop: The current running event loop

Raises:

Type Description
RuntimeError

If no event loop is running with helpful guidance

Source code in doc_env/lib/python3.13/site-packages/radical/asyncflow/utils.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def get_event_loop_or_raise(
    context_name: str = "AsyncWorkflowEngine",
) -> asyncio.AbstractEventLoop:
    """
    Get the current running event loop or raise a helpful error.

    Args:
        context_name: Name of the class/context for error messages

    Returns:
        asyncio.AbstractEventLoop: The current running event loop

    Raises:
        RuntimeError: If no event loop is running with helpful guidance
    """
    try:
        return asyncio.get_running_loop()
    except RuntimeError as e:
        raise RuntimeError(
            f"{context_name} must be created within an async context. "
            f"Use 'await {context_name}.create(...)' from within an async function, "
            "or run within asyncio.run()."
        ) from e