|
7 | 7 |
|
8 | 8 | import { TypeScriptExample } from "~/components"; |
9 | 9 |
|
10 | | -Execute Python, JavaScript, and TypeScript code with support for data visualizations, tables, and rich output formats. Contexts maintain state (variables, imports, functions) across executions. |
| 10 | +Execute Python, JavaScript, and TypeScript code with support for data visualizations, tables, and rich output formats. Contexts maintain state (variables, imports, functions) across executions with complete isolation between contexts. |
11 | 11 |
|
12 | 12 | ## Methods |
13 | 13 |
|
@@ -40,7 +40,7 @@ const ctx = await sandbox.createCodeContext({ |
40 | 40 | </TypeScriptExample> |
41 | 41 |
|
42 | 42 | :::note[Context isolation] |
43 | | -Each code context is completely isolated from other contexts. Variables, imports, functions, and state defined in one context are never accessible to another context. Each context has a dedicated executor process from creation to deletion, ensuring complete isolation even under heavy concurrent usage. |
| 43 | +Each code context is completely isolated from other contexts. Variables, imports, functions, and state defined in one context are never accessible to another context. Each context has a dedicated executor process from creation to deletion, ensuring complete isolation even under heavy concurrent usage. The system automatically scales to support as many concurrent contexts as needed without artificial limits. |
44 | 44 | ::: |
45 | 45 |
|
46 | 46 | ### `runCode()` |
@@ -87,7 +87,10 @@ await Promise.all([ |
87 | 87 | </TypeScriptExample> |
88 | 88 |
|
89 | 89 | :::note[Default context behavior] |
90 | | -If no `context` is provided, a default context is automatically created/reused for the specified `language`. While convenient for quick tests, **explicitly creating contexts is recommended** for production use to maintain predictable state. |
| 90 | +If no `context` is provided, a default context is automatically created/reused for the specified `language`. While convenient for quick tests, **explicitly creating contexts is recommended** for production use to: |
| 91 | +- Maintain predictable state across executions |
| 92 | +- Enable concurrent execution by creating multiple contexts |
| 93 | +- Ensure proper resource cleanup when contexts are deleted |
91 | 94 |
|
92 | 95 | <TypeScriptExample> |
93 | 96 | ``` |
|
0 commit comments