> ## 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.

# Verouderde inactiviteitstime-out

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/nl/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>
  Deze verouderde pagina wordt bewaard voor gebruikers die nog de 1.x- of bèta-SDK-lijn gebruiken. Nieuwe SDK 2.x-integraties moeten de huidige Sandbox-documentatie volgen.
</Warning>

<SandboxBetaVersionWarning />

We kunnen voor elke sandbox een time-out instellen (raadpleeg [Levenscyclusbeheer](/docs/nl/guides/sandbox-lifecycle)). Wanneer de looptijd van de sandbox de time-out bereikt, wordt de sandbox automatisch beëindigd. In sommige scenario's kunnen we de verwachte looptijd van de sandbox echter niet bepalen, maar willen we dat de sandbox automatisch wordt beëindigd wanneer deze niet in gebruik is om kosten te besparen. In dat geval kunt u de functie **"Inactiviteitstime-out"** gebruiken.

Bij het maken van een sandbox kunnen we de parameter `idle_timeout` instellen in de metadata (eenheid: seconden, minimum is 60) om de functie **"Inactiviteitstime-out"** in te schakelen. Zodra deze is ingeschakeld, beëindigt het systeem de sandbox-instantie wanneer het detecteert dat de sandbox binnen de opgegeven tijdsperiode geen bewerkingen heeft (commando's uitvoeren, code uitvoeren, bestandsbewerkingen, enz.). Anders blijft de sandbox actief totdat deze de maximale tijdslimiet voor sandbox-uitvoering bereikt (momenteel standaard 3600 seconden).

Raadpleeg het volgende voorbeeld:

<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>
