zlacker

[return to "Microsandbox: Virtual Machines that feel and perform like containers"]
1. appcyp+Y6[view] [source] 2025-05-30 14:11:40
>>makebo+(OP)
Thanks for sharing!

I'm the creator of microsandbox. If there is anything you need to know about the project, let me know.

This project is meant to make creating microvms from your machine as easy as using Docker containers.

Ask me anything.

◧◩
2. simonw+nT[view] [source] 2025-05-30 19:55:27
>>appcyp+Y6
I'm trying this out now and it's very promising. One problem I'm running into with the Python library is that I'd like to keep that sandbox running for several minutes while I do things like set variables in one call and then use them for stuff several calls later. I keep seeing this error intermittently:

    Error: Sandbox is not started. Call start() first
Is there a suggested way of keeping a sandbox around for longer?

The documented code pattern is this:

    async def main():
        async with PythonSandbox.create(name="my-sandbox") as sb:
            exec = await sb.run("print('Hello, World!')")
            print(await exec.output())
Due to the way my code works I want to instantiate the sandbox once for a specific class and then have multiple calls to it by class methods, which isn't a clean fit for that "async with" pattern.

Any recommendations?

◧◩◪
3. gcharb+L41[view] [source] 2025-05-30 21:39:01
>>simonw+nT
async with is just syntactic sugar. You could very well call __aenter__ and __aexit__ manually. You could also use an AsyncExitStack, call __aenter__ manually, then enter_async_context, and call aclose when you’re done. Since aclose method exists I guess this is not an anti-pattern.

https://docs.python.org/3/library/contextlib.html#contextlib...

[go to top]