Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ipython@9.5.x
tile.json

tessl/pypi-ipython

tessl install tessl/pypi-ipython@9.5.0

IPython: Productive Interactive Computing - An advanced interactive computing environment and command shell for Python.

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.09x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-1/

Async Code Executor

Build a utility that demonstrates asynchronous code execution capabilities in an interactive Python environment, allowing users to run async code snippets and manage different event loop backends.

Overview

Create a Python module that provides an interactive code execution environment supporting asynchronous operations. The utility should enable execution of async code with top-level await support and demonstrate integration with different async loop runners.

Requirements

Core Functionality

The module must provide:

  1. Interactive Shell Initialization: Initialize an interactive Python session that supports async code execution
  2. Async Code Execution: Execute code cells containing async/await syntax with proper handling of coroutines
  3. Top-Level Await Support: Enable direct use of await expressions at the top level without wrapping in async functions
  4. Loop Runner Configuration: Support configuring and switching between different async event loop backends (asyncio, trio, curio)

Implementation Details

Your implementation should:

  • Provide a function create_async_shell() that returns an initialized interactive shell instance capable of running async code
  • Implement a function execute_async_code(shell, code, loop_runner='asyncio') that:
    • Takes a shell instance, code string, and optional loop runner specification
    • Executes the code with the specified async loop backend
    • Returns the execution result
    • Handles both synchronous and asynchronous code properly
  • Demonstrate setting autoawait mode to enable top-level await
  • Handle execution of code containing await statements without requiring explicit async def wrappers

Test Cases

  • Executing code "await asyncio.sleep(0.01); result = 42" in a shell sets the variable result to 42 in the user namespace @test
  • Creating a shell with autoawait enabled and executing "import asyncio; await asyncio.sleep(0.01)" completes without raising an exception @test
  • Configuring a shell to use 'trio' loop runner and executing trio-based async code completes successfully @test

Dependencies { .dependencies }

IPython { .dependency }

Provides interactive computing environment with async execution support.

Implementation

@generates

API

def create_async_shell():
    """
    Create and configure an interactive shell with async support enabled.

    Returns:
        An interactive shell instance configured for async code execution
    """
    pass

def execute_async_code(shell, code, loop_runner='asyncio'):
    """
    Execute code in the shell with specified async loop runner.

    Args:
        shell: Interactive shell instance
        code: Python code string to execute (may contain async/await)
        loop_runner: Event loop backend ('asyncio', 'trio', or 'curio')

    Returns:
        Execution result from running the code
    """
    pass

def configure_autoawait(shell, enabled=True):
    """
    Enable or disable autoawait mode for top-level await support.

    Args:
        shell: Interactive shell instance
        enabled: Whether to enable autoawait mode
    """
    pass