Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds filtering sandboxes by state in the SDKs #564

Open
wants to merge 19 commits into
base: beta
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added docs for removing paused sandboxes
  • Loading branch information
mishushakov committed Feb 5, 2025
commit 6bc1c1be0be5855dc28267e56aa79c06ec7ea986
43 changes: 42 additions & 1 deletion apps/web/src/app/(docs)/docs/sandbox/persistence/page.mdx
Copy link
Member

@mlejva mlejva Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mishushakov will deleting paused sandboxes be included in a separate PR? I'm asking because the new docs addition doesn't mention anything about deleting paused sandboxes.

Other than that, this looks good to me on the docs level

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will be a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I have decided to add it here as well to avoid merge conflicts

Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ console.log('Paused sandboxes', sandboxes)
```
```python
from e2b import Sandbox

# or use Core: https://github.com/e2b-dev/e2b
# from e2b import Sandbox
#
Expand All @@ -159,6 +158,48 @@ print('Paused sandboxes', sandboxes)
```
</CodeGroup>

## 5. Removing paused sandboxes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is js and python little bit different, also could you unify word id, sometimes you have it in lowercase and it other instance in uppercase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example?


You can remove paused (and running!) sandboxes by calling the `kill` method on the Sandbox instance.

<CodeGroup>
```js
import { Sandbox } from '@e2b/code-interpreter'
// or use Core: https://github.com/e2b-dev/e2b
// import { Sandbox } from 'e2b'
//
// or use Desktop: https://github.com/e2b-dev/desktop
// import { Sandbox } from '@e2b/desktop'

const sbx = await Sandbox.create()
console.log('Sandbox created', sbx.sandboxId)

// Pause the sandbox
// You can save the sandbox ID in your database
// to resume the sandbox later
const sandboxId = await sbx.pause()

// Remove the sandbox
await sbx.kill()
```
```python
from e2b import Sandbox
# or use Core: https://github.com/e2b-dev/e2b
# from e2b import Sandbox
#
# or use Desktop: https://github.com/e2b-dev/desktop
# from e2b_desktop import Sandbox

sbx = Sandbox()

# Pause the sandbox
sandbox_id = sbx.pause()

# Remove the sandbox
sbx.kill()
```
</CodeGroup>

## Sandbox's timeout
When you resume a sandbox, the sandbox's timeout is reset to the default timeout of an E2B sandbox - 5 minutes.

Expand Down