2026-01-14 07:19:34 +08:00
|
|
|
from src.sandbox.local.local_sandbox import LocalSandbox
|
|
|
|
|
from src.sandbox.sandbox_provider import SandboxProvider
|
|
|
|
|
|
|
|
|
|
_singleton: LocalSandbox | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LocalSandboxProvider(SandboxProvider):
|
2026-01-15 13:22:30 +08:00
|
|
|
def acquire(self, thread_id: str | None = None) -> str:
|
2026-01-14 07:19:34 +08:00
|
|
|
global _singleton
|
|
|
|
|
if _singleton is None:
|
|
|
|
|
_singleton = LocalSandbox("local")
|
|
|
|
|
return _singleton.id
|
|
|
|
|
|
|
|
|
|
def get(self, sandbox_id: str) -> None:
|
2026-01-14 12:32:34 +08:00
|
|
|
if sandbox_id == "local":
|
|
|
|
|
if _singleton is None:
|
|
|
|
|
self.acquire()
|
|
|
|
|
return _singleton
|
|
|
|
|
return None
|
2026-01-14 07:19:34 +08:00
|
|
|
|
|
|
|
|
def release(self, sandbox_id: str) -> None:
|
|
|
|
|
pass
|