> ## Documentation Index
> Fetch the complete documentation index at: https://novita.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy-Leerlauf-Timeout

export const SandboxBetaVersionWarning = () => {
  if (typeof document === "undefined") {
    return null;
  } else {
    return <Warning>The following legacy features require the legacy SDK and CLI versions listed in <Link href="/docs/de/guides/sandbox-legacy-e2b-compatible" target="self">Legacy SDKs & CLI</Link>. Please note that legacy features may be less stable than production releases. If you encounter any issues while using these features, please <Link href="https://meetings-na2.hubspot.com/junyu" target="_blank">contact us</Link>.</Warning>;
  }
};

<Warning>
  Diese Legacy-Seite wird für Benutzer beibehalten, die weiterhin die SDK-Reihe 1.x oder beta verwenden. Neue Integrationen mit SDK 2.x sollten der aktuellen Sandbox-Dokumentation folgen.
</Warning>

<SandboxBetaVersionWarning />

Wir können für jede Sandbox ein Timeout festlegen (siehe [Lebenszyklusverwaltung](/docs/de/guides/sandbox-lifecycle)). Wenn die Laufzeit der Sandbox das Timeout erreicht, wird die Sandbox automatisch beendet. In manchen Szenarien können wir die erwartete Laufzeit der Sandbox jedoch nicht bestimmen, möchten aber, dass die Sandbox automatisch beendet wird, wenn sie nicht verwendet wird, um Kosten zu sparen. In diesem Fall können Sie die Funktion **„Leerlauf-Timeout“** verwenden.

Beim Erstellen einer Sandbox können wir den Parameter `idle_timeout` in den Metadaten festlegen (Einheit: Sekunden, Minimum ist 60), um die Funktion **„Leerlauf-Timeout“** zu aktivieren. Nach der Aktivierung beendet das System die Sandbox-Instanz, wenn erkannt wird, dass die Sandbox innerhalb des angegebenen Zeitraums keine Vorgänge ausführt (Befehle ausführen, Code ausführen, Dateioperationen usw.). Andernfalls läuft die Sandbox weiter, bis sie das maximale Zeitlimit für den Sandbox-Betrieb erreicht (derzeit standardmäßig 3600 Sekunden).

Bitte beachten Sie das folgende Beispiel:

<CodeGroup>
  ```js JavaScript & TypeScript icon="js" theme={"system"}
  import { Sandbox } from 'novita-sandbox/code-interpreter';

  const sandbox = await Sandbox.create(
      {
          metadata: { "idle_timeout": "60" }
      }
  );
  console.log('Sandbox created', sandbox.sandboxId)

  const result = await sandbox.commands.run('ls -al')
  console.log('Command result', result)

  await new Promise(resolve => setTimeout(resolve, 90000));

  const isRunning = await sandbox.isRunning()
  console.log('Sandbox is running', isRunning)

  await sandbox.kill()
  ```

  ```python Python icon="python" theme={"system"}
  from novita_sandbox.core import Sandbox
  import time

  sandbox = Sandbox.create(
      metadata={"idle_timeout": "60"}  # Minimum time is 60s, you can customize it
  )
  print('Sandbox created', sandbox.sandbox_id)

  result = sandbox.commands.run('ls -al')
  print('Command result', result)

  print('Waiting for 90 seconds...')
  time.sleep(90)

  is_running = sandbox.is_running()
  print('Sandbox is running', is_running)

  sandbox.kill()
  ```
</CodeGroup>
