Skip to content

Commit ca19aad

Browse files
committed
Improve speed in python sdk
1 parent 7a16259 commit ca19aad

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

python/e2b_code_interpreter/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import json
2+
import threading
23
import time
34
import uuid
4-
from concurrent.futures import ThreadPoolExecutor, Future
5+
from concurrent.futures import Future
56
from typing import Any, Callable, List, Optional
67

78
import requests
@@ -119,8 +120,7 @@ def set_kernel_id():
119120
self._sandbox.filesystem.read("/root/.jupyter/kernel_id", timeout=timeout).strip()
120121
)
121122

122-
with ThreadPoolExecutor(thread_name_prefix="e2b-get-default-kernel-id") as executor:
123-
executor.submit(set_kernel_id)
123+
threading.Thread(target=set_kernel_id).start()
124124

125125
def _connect_kernel(self, kernel_id: str, timeout: Optional[float] = TIMEOUT):
126126
return create_connection(
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
sandbox.close()
2929

3030

31-
print(f"Average Create Sandbox Time: {createSandboxTime / iterations}ms")
32-
print(f"Average Execute Python x = 1 Time: {exec_python_x_equals_1_time / iterations}ms")
33-
print(f"Average Execute Python x+=1; x Time: {exec_python_x_plus_equals_1_time / iterations}ms")
31+
print(f"Average Create Sandbox Time: {createSandboxTime / iterations}s")
32+
print(f"Average Execute Python x = 1 Time: {exec_python_x_equals_1_time / iterations}s")
33+
print(f"Average Execute Python x+=1; x Time: {exec_python_x_plus_equals_1_time / iterations}s")

0 commit comments

Comments
 (0)