Search documentation of Metastatic

# Metastatic.Supplemental.Python.Asyncio (Metastatic v0.2.0)

View Source

Supplemental module for Python's `asyncio` library.

Transforms async/await constructs into asyncio API calls. This supplemental handles:

- `:async_await` - async/await patterns → asyncio.run()
- `:async_context` - async context managers → async with
- `:gather` - parallel execution → asyncio.gather()

## Examples

    # Transform async function call
    iex> ast = {:async_operation, :async_await,
    ...>   {:function_call, "fetch_data", [
    ...>     {:literal, :string, "https://api.example.com"}
    ...>   ]}}
    iex> {:ok, result} = Metastatic.Supplemental.Python.Asyncio.transform(ast, :python, %{})
    iex> match?({:function_call, "asyncio.run", _}, result)
    true

    # Transform gather for parallel execution
    iex> ast = {:async_operation, :gather, [
    ...>   {:function_call, "fetch_user", [{:literal, :integer, 1}]},
    ...>   {:function_call, "fetch_posts", [{:literal, :integer, 1}]}
    ...> ]}
    iex> {:ok, result} = Metastatic.Supplemental.Python.Asyncio.transform(ast, :python, %{})
    iex> match?({:function_call, "asyncio.gather", _}, result)
    true