Skip to main content

Overview

The Narada Python SDK supports parallel execution, allowing you to run multiple automation tasks simultaneously across different browser windows. This feature significantly improves efficiency when you need to perform multiple independent operations.
Each browser window operates independently, so you can run completely different automation tasks in parallel without interference.

Parallel Execution Example

Watch this demonstration of running multiple automation tasks simultaneously:
You can also view the complete example code on GitHub:

View Complete Example Code

See the full parallel execution example on GitHub

How It Works

Each browser window operates independently, so you can run completely different automation tasks in parallel without interference. Use Python’s asyncio.gather to run tasks concurrently:
import asyncio
from narada import Agent, BrowserEnvironment
from pydantic import BaseModel, Field

class CompanyInfo(BaseModel):
    name: str = Field(description="Company name")
    valuation: str = Field(description="Company valuation")

async def research_company(company_name: str) -> CompanyInfo:
    """Research a single company in its own browser environment."""
    env = BrowserEnvironment()
    agent = Agent(environment=env)

    try:
        await agent.go_to_url(
            url=f"https://www.google.com/search?q={company_name}+valuation",
            new_tab=True
        )

        response = await agent.run(
            prompt=f"Extract the company name and latest valuation for {company_name}",
            output_schema=CompanyInfo
        )

        result = response.structured_output
        assert result is not None
        return result
    finally:
        await env.close()

async def main():
    companies = ["Apple", "Google", "Microsoft", "Amazon"]

    # Run all research tasks in parallel, each gets its own browser environment.
    results = await asyncio.gather(*[
        research_company(name) for name in companies
    ])

    for result in results:
        print(f"{result.name}: {result.valuation}")

if __name__ == "__main__":
    asyncio.run(main())
Each BrowserEnvironment() creates an independent browser target. You can also use Cloud Browser Sessions for parallel cloud-based execution without local Chrome.