AsyncTemplate
class AsyncTemplate(TemplateBase)
Asynchronous template builder for E2B sandboxes.
build
@staticmethod
async def build(template: TemplateClass,
alias: str,
cpu_count: int = 2,
memory_mb: int = 1024,
skip_cache: bool = False,
on_build_logs: Optional[Callable[[LogEntry], None]] = None,
api_key: Optional[str] = None,
domain: Optional[str] = None) -> None
Build and deploy a template to E2B infrastructure.
Arguments:
template
: The template to buildalias
: Alias name for the templatecpu_count
: Number of CPUs allocated to the sandboxmemory_mb
: Amount of memory in MB allocated to the sandboxskip_cache
: If True, forces a complete rebuild ignoring cacheon_build_logs
: Callback function to receive build logs during the build processapi_key
: E2B API key for authenticationdomain
: Domain of the E2B API Example
from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_python_image('3')
.copy('requirements.txt', '/home/user/')
.run_cmd('pip install -r /home/user/requirements.txt')
)
await AsyncTemplate.build(
template,
alias='my-python-env',
cpu_count=2,
memory_mb=1024
)