Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix watch bug; [WIP] Timeout bug

Tomas Valentaf530f767eec1
diff --git a/packages/js-sdk/tests/sandbox/files/watch.test.ts b/packages/js-sdk/tests/sandbox/files/watch.test.ts
index 36ec01016..d5ed5913c 100644
--- a/packages/js-sdk/tests/sandbox/files/watch.test.ts
+++ b/packages/js-sdk/tests/sandbox/files/watch.test.ts
@@ -26,7 +26,6 @@ sandboxTest('watch directory changes', async ({ sandbox }) => {
})
await sandbox.files.write(`${dirname}/${filename}`, newContent)
- await new Promise(resolve => setTimeout(resolve, 1000)) // wait for the event to be triggered
await eventPromise
diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py
index c9b131c19..aefdb05bd 100644
--- a/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py
+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py
@@ -1,4 +1,4 @@
-import anyio
+import asyncio
import inspect
from typing import Any, AsyncGenerator, Optional
@@ -20,12 +20,12 @@ class AsyncWatchHandle:
self._on_event = on_event
self._on_exit = on_exit
- self._tg = anyio.create_task_group()
- self._tg.start_soon(self._handle_events)
+ self._wait = asyncio.create_task(self._handle_events())
async def close(self):
- self._tg.cancel_scope.cancel()
- await self._events.aclose()
+ self._wait.cancel()
+ # BUG: In Python 3.8 closing async generator can throw RuntimeError.
+ # await self._events.aclose()
async def _iterate_events(self):
try:
diff --git a/packages/python-sdk/e2b/sandbox_async/process/process_handle.py b/packages/python-sdk/e2b/sandbox_async/process/process_handle.py
index 05d8f574a..206de17d1 100644
--- a/packages/python-sdk/e2b/sandbox_async/process/process_handle.py
+++ b/packages/python-sdk/e2b/sandbox_async/process/process_handle.py
@@ -1,4 +1,4 @@
-import anyio
+import asyncio
import inspect
from typing import (
Optional,
@@ -69,14 +69,7 @@ class AsyncProcessHandle:
self._result: Optional[ProcessResult] = None
self._iteration_exception: Optional[Exception] = None
- self._tg = anyio.create_task_group()
- self._wait = anyio.Event()
-
- async def wait():
- await self._handle_events()
- self._wait.set()
-
- self._tg.start_soon(wait)
+ self._wait = asyncio.create_task(self._handle_events())
async def _iterate_events(
self,
@@ -84,30 +77,28 @@ class AsyncProcessHandle:
Union[Tuple[Stdout, None], Tuple[None, Stderr]],
None,
]:
- try:
- async for event in self._events:
- if event.event.HasField("data"):
- if event.event.data.stdout:
- out = event.event.data.stdout.decode()
- self._stdout += out
- yield out, None
- if event.event.data.stderr:
- out = event.event.data.stderr.decode()
- self._stderr += out
- yield None, out
- if event.event.HasField("end"):
- self._result = ProcessResult(
- stdout=self._stdout,
- stderr=self._stderr,
- exit_code=event.event.end.exit_code,
- error=event.event.end.error,
- )
- finally:
- await self.disconnect()
+ async for event in self._events:
+ if event.event.HasField("data"):
+ if event.event.data.stdout:
+ out = event.event.data.stdout.decode()
+ self._stdout += out
+ yield out, None
+ if event.event.data.stderr:
+ out = event.event.data.stderr.decode()
+ self._stderr += out
+ yield None, out
+ if event.event.HasField("end"):
+ self._result = ProcessResult(
+ stdout=self._stdout,
+ stderr=self._stderr,
+ exit_code=event.event.end.exit_code,
+ error=event.event.end.error,
+ )
async def disconnect(self) -> None:
- self._tg.cancel_scope.cancel()
- await self._events.aclose()
+ self._wait.cancel()
+ # BUG: In Python 3.8 closing async generator can throw RuntimeError.
+ # await self._events.aclose()
async def _handle_events(self):
try:
@@ -120,7 +111,7 @@ class AsyncProcessHandle:
cb = self._on_stderr(stderr)
if inspect.isawaitable(cb):
await cb
- except StopIteration:
+ except StopAsyncIteration:
pass
except Exception as e:
self._iteration_exception = handle_rpc_exception(e)
@@ -142,8 +133,7 @@ class AsyncProcessHandle:
return self._result
async def wait(self) -> ProcessResult:
- await self._wait.wait()
-
+ await self._wait
if self._iteration_exception:
raise self._iteration_exception
@@ -161,5 +151,5 @@ class AsyncProcessHandle:
return self._result
async def kill(self):
- self._tg.cancel_scope.cancel()
+ # self._wait.cancel()
await self._handle_kill()
diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.py
index 8b5e07a41..3a876afd8 100644
--- a/packages/python-sdk/example.py
+++ b/packages/python-sdk/example.py
@@ -11,11 +11,12 @@ logging.basicConfig(level=logging.ERROR)
async def main():
- for _ in range(10):
- start = time.time()
- sbx = await AsyncSandbox.create(timeout=10)
- end = time.time()
- print(f"Time taken: {end - start}")
+ sbx = await AsyncSandbox.create(timeout=10)
+ await sbx.commands.run("sleep 10", timeout=1000)
+ # for _ in range(10):
+ # start = time.time()
+ # end = time.time()
+ # print(f"Time taken: {end - start}")
if __name__ == "__main__":
diff --git a/packages/python-sdk/poetry.lock b/packages/python-sdk/poetry.lock
index 0190addd6..6f1f51e27 100644
--- a/packages/python-sdk/poetry.lock
+++ b/packages/python-sdk/poetry.lock
@@ -335,6 +335,24 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
+[[package]]
+name = "pytest-asyncio"
+version = "0.23.7"
+description = "Pytest support for asyncio"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "pytest_asyncio-0.23.7-py3-none-any.whl", hash = "sha256:009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b"},
+ {file = "pytest_asyncio-0.23.7.tar.gz", hash = "sha256:5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268"},
+]
+
+[package.dependencies]
+pytest = ">=7.0.0,<9"
+
+[package.extras]
+docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"]
+testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"]
+
[[package]]
name = "pytest-dotenv"
version = "0.5.2"
@@ -445,4 +463,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
-content-hash = "fb057b723b0e97a0757c61b2ddf1967d7e601755005076fd9dadf04be9f1c5f1"
+content-hash = "c1302204f65dae715087a5509ee7bb377ca91e2fa6707326adc911d7a409398d"
diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml
index b94696377..93950901c 100644
--- a/packages/python-sdk/pyproject.toml
+++ b/packages/python-sdk/pyproject.toml
@@ -17,7 +17,6 @@ protobuf = "^5.26.1"
httpcore = "^1.0.5"
httpx = "^0.27.0"
attrs = "^23.2.0"
-anyio = "^4.4.0"
[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
@@ -25,6 +24,7 @@ pytest = "^7.4.0"
pytest-xdist = "^3.3.1"
python-dotenv = "^1.0.0"
pytest-dotenv = "^0.5.2"
+pytest-asyncio = "^0.23.7"
[build-system]
requires = ["poetry-core"]
diff --git a/packages/python-sdk/tests/async/api_async/test_sbx_kill.py b/packages/python-sdk/tests/async/api_async/test_sbx_kill.py
index 991880d86..0276e6e67 100644
--- a/packages/python-sdk/tests/async/api_async/test_sbx_kill.py
+++ b/packages/python-sdk/tests/async/api_async/test_sbx_kill.py
@@ -4,7 +4,7 @@ from e2b import AsyncSandbox
@pytest.mark.skip_debug()
async def test_kill_existing_sandbox(async_sandbox: AsyncSandbox):
assert await AsyncSandbox.kill(async_sandbox.sandbox_id) == True
@@ -13,6 +13,6 @@ async def test_kill_existing_sandbox(async_sandbox: AsyncSandbox):
@pytest.mark.skip_debug()
async def test_kill_non_existing_sandbox():
assert await AsyncSandbox.kill("non-existing-sandbox") == False
diff --git a/packages/python-sdk/tests/async/api_async/test_sbx_list.py b/packages/python-sdk/tests/async/api_async/test_sbx_list.py
index 2d466df9b..a661bfc13 100644
--- a/packages/python-sdk/tests/async/api_async/test_sbx_list.py
+++ b/packages/python-sdk/tests/async/api_async/test_sbx_list.py
@@ -4,7 +4,7 @@ from e2b import AsyncSandbox
@pytest.mark.skip_debug()
async def test_list_sandboxes(async_sandbox: AsyncSandbox):
sandboxes = await AsyncSandbox.list()
assert len(sandboxes) > 0
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_connect.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_connect.py
index c80a35b6d..24e46f129 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_connect.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_connect.py
@@ -3,7 +3,7 @@ import pytest
from e2b import NotFoundException, AsyncSandbox
async def test_connect_to_process(async_sandbox: AsyncSandbox):
cmd = await async_sandbox.commands.run("sleep 10", background=True)
pid = cmd.pid
@@ -12,7 +12,7 @@ async def test_connect_to_process(async_sandbox: AsyncSandbox):
assert process_info.pid == pid
async def test_connect_to_non_existing_process(async_sandbox: AsyncSandbox):
non_existing_pid = 999999
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py
index d54b5ade7..5d89daef1 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox, ProcessExitException
async def test_kill_process(async_sandbox: AsyncSandbox):
cmd = await async_sandbox.commands.run("sleep 10", background=True)
pid = cmd.pid
@@ -14,7 +14,7 @@ async def test_kill_process(async_sandbox: AsyncSandbox):
await async_sandbox.commands.run(f"kill -0 {pid}")
async def test_kill_non_existing_process(async_sandbox: AsyncSandbox):
non_existing_pid = 999999
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
index 154f44097..372eb483c 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_kill_process(async_sandbox: AsyncSandbox):
c1 = await async_sandbox.commands.run("sleep 10", background=True)
c2 = await async_sandbox.commands.run("sleep 10", background=True)
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
index cebd82648..87cd1af53 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_run(async_sandbox: AsyncSandbox):
text = "Hello, World!"
@@ -13,7 +13,7 @@ async def test_run(async_sandbox: AsyncSandbox):
assert cmd.stdout == f"{text}\n"
async def test_run_with_special_characters(async_sandbox: AsyncSandbox):
text = "!@#$%^&*()_+"
@@ -23,7 +23,7 @@ async def test_run_with_special_characters(async_sandbox: AsyncSandbox):
assert cmd.stdout == f"{text}\n"
async def test_run_with_multiline_string(async_sandbox: AsyncSandbox):
text = "Hello,\nWorld!"
@@ -33,14 +33,14 @@ async def test_run_with_multiline_string(async_sandbox: AsyncSandbox):
assert cmd.stdout == f"{text}\n"
async def test_run_with_timeout(async_sandbox: AsyncSandbox):
cmd = await async_sandbox.commands.run('echo "Hello, World!"', timeout=1000)
assert cmd.exit_code == 0
async def test_run_with_too_short_timeout(async_sandbox: AsyncSandbox):
with pytest.raises(Exception):
await async_sandbox.commands.run("sleep 10", timeout=1000)
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_send_stdin.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_send_stdin.py
index 56939005c..daaeac28b 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_send_stdin.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_send_stdin.py
@@ -1,34 +1,61 @@
import pytest
-import anyio
+import asyncio
from e2b import AsyncSandbox
async def test_send_stdin_to_process(async_sandbox: AsyncSandbox):
- cmd = await async_sandbox.commands.run("cat", background=True)
+ ev = asyncio.Event()
+
+ def handle_event(stdout: str):
+ ev.set()
+
+ cmd = await async_sandbox.commands.run(
+ "cat",
+ background=True,
+ on_stdout=handle_event,
+ )
await async_sandbox.commands.send_stdin(cmd.pid, "Hello, World!")
- await anyio.sleep(2)
+ await ev.wait()
assert cmd.stdout == "Hello, World!"
async def test_send_special_characters_to_process(async_sandbox: AsyncSandbox):
- cmd = await async_sandbox.commands.run("cat", background=True)
+ ev = asyncio.Event()
+
+ def handle_event(stdout: str):
+ ev.set()
+
+ cmd = await async_sandbox.commands.run(
+ "cat",
+ background=True,
+ on_stdout=handle_event,
+ )
await async_sandbox.commands.send_stdin(cmd.pid, "!@#$%^&*()_+")
- await anyio.sleep(2)
+ await ev.wait()
assert cmd.stdout == "!@#$%^&*()_+"
async def test_send_multiline_string_to_process(async_sandbox: AsyncSandbox):
- cmd = await async_sandbox.commands.run("cat", background=True)
+ ev = asyncio.Event()
+
+ def handle_event(stdout: str):
+ ev.set()
+
+ cmd = await async_sandbox.commands.run(
+ "cat",
+ background=True,
+ on_stdout=handle_event,
+ )
await async_sandbox.commands.send_stdin(cmd.pid, "Hello,\nWorld!")
- await anyio.sleep(2)
+ await ev.wait()
assert cmd.stdout == "Hello,\nWorld!"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py b/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
index 21cd19240..dc7057d6b 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_exists(async_sandbox: AsyncSandbox):
filename = "test_exists.txt"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_files_list.py b/packages/python-sdk/tests/async/sandbox_async/files/test_files_list.py
index 01050c9d7..7a527811a 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_files_list.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_files_list.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox, FileType
async def test_list_directory(async_sandbox: AsyncSandbox):
dir_name = "test_directory"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_make_dir.py b/packages/python-sdk/tests/async/sandbox_async/files/test_make_dir.py
index 3dfb580f9..e95b98866 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_make_dir.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_make_dir.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_make_directory(async_sandbox: AsyncSandbox):
dir_name = "test_directory"
@@ -12,7 +12,7 @@ async def test_make_directory(async_sandbox: AsyncSandbox):
assert exists
async def test_make_nested_directory(async_sandbox: AsyncSandbox):
nested_dir_name = "test_directory/nested_directory"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_read.py b/packages/python-sdk/tests/async/sandbox_async/files/test_read.py
index 25fbdc8bc..164cae5da 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_read.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_read.py
@@ -3,7 +3,7 @@ import pytest
from e2b import NotFoundException, AsyncSandbox
async def test_read_file(async_sandbox: AsyncSandbox):
filename = "test_read.txt"
content = "Hello, world!"
@@ -13,7 +13,7 @@ async def test_read_file(async_sandbox: AsyncSandbox):
assert read_content == content
async def test_read_non_existing_file(async_sandbox: AsyncSandbox):
filename = "non_existing_file.txt"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py b/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
index 403ae280d..f1c69dd86 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_remove_file(async_sandbox: AsyncSandbox):
filename = "test_remove.txt"
content = "This file will be removed."
@@ -14,7 +14,7 @@ async def test_remove_file(async_sandbox: AsyncSandbox):
assert not exists
async def test_remove_non_existing_file(async_sandbox: AsyncSandbox):
filename = "non_existing_file.txt"
await async_sandbox.files.remove(filename)
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_rename.py b/packages/python-sdk/tests/async/sandbox_async/files/test_rename.py
index 7ecc7320a..24bd8e1fb 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_rename.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_rename.py
@@ -3,7 +3,7 @@ import pytest
from e2b import NotFoundException, AsyncSandbox
async def test_rename_file(async_sandbox: AsyncSandbox):
old_filename = "test_rename_old.txt"
new_filename = "test_rename_new.txt"
@@ -19,7 +19,7 @@ async def test_rename_file(async_sandbox: AsyncSandbox):
assert read_content == content
async def test_rename_non_existing_file(async_sandbox: AsyncSandbox):
old_filename = "non_existing_file.txt"
new_filename = "new_non_existing_file.txt"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py b/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py
index 7f09825f3..d2bf3c4a7 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py
@@ -5,7 +5,7 @@ from asyncio import Event
from e2b import NotFoundException, AsyncSandbox, FilesystemEvent, FilesystemEventType
async def test_watch_directory_changes(async_sandbox: AsyncSandbox):
dirname = "test_watch_dir"
filename = "test_watch.txt"
@@ -30,7 +30,7 @@ async def test_watch_directory_changes(async_sandbox: AsyncSandbox):
await handle.close()
async def test_watch_non_existing_directory(async_sandbox: AsyncSandbox):
dirname = "non_existing_watch_dir"
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_write.py b/packages/python-sdk/tests/async/sandbox_async/files/test_write.py
index bcd43e46d..b0fc9e072 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_write.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_write.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_write_file(async_sandbox: AsyncSandbox):
filename = "test_write.txt"
content = "This is a test file."
@@ -16,7 +16,7 @@ async def test_write_file(async_sandbox: AsyncSandbox):
assert read_content == content
async def test_overwrite_file(async_sandbox: AsyncSandbox):
filename = "test_overwrite.txt"
initial_content = "Initial content."
@@ -28,7 +28,7 @@ async def test_overwrite_file(async_sandbox: AsyncSandbox):
assert read_content == new_content
async def test_write_to_non_existing_directory(async_sandbox: AsyncSandbox):
filename = "non_existing_dir/test_write.txt"
content = "This should succeed too."
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_connect.py b/packages/python-sdk/tests/async/sandbox_async/test_connect.py
index 7655098d5..651ca23d5 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_connect.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_connect.py
@@ -3,7 +3,7 @@ import pytest
from e2b import AsyncSandbox
async def test_connect(template):
sbx = await AsyncSandbox.create(template, timeout=10)
assert await sbx.is_running()
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_create.py b/packages/python-sdk/tests/async/sandbox_async/test_create.py
index 6cb1ed671..cee667c62 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_create.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_create.py
@@ -4,14 +4,14 @@ from e2b import AsyncSandbox
@pytest.mark.skip_debug()
async def test_start(template):
sbx = await AsyncSandbox.create(template, timeout=5)
assert await sbx.is_running()
@pytest.mark.skip_debug()
async def test_metadata(template):
sbx = await AsyncSandbox.create(
template, timeout=5, metadata={"test-key": "test-value"}
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_host.py b/packages/python-sdk/tests/async/sandbox_async/test_host.py
index c4fad88f9..624d0e421 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_host.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_host.py
@@ -6,7 +6,7 @@ from time import sleep
from e2b import AsyncSandbox
async def test_ping_server(async_sandbox: AsyncSandbox, debug):
cmd = await async_sandbox.commands.run(
"python -m http.server 8000",
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_kill.py b/packages/python-sdk/tests/async/sandbox_async/test_kill.py
index d59430dc9..19c1cf040 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_kill.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_kill.py
@@ -4,7 +4,7 @@ from e2b import AsyncSandbox
@pytest.mark.skip_debug()
async def test_kill(async_sandbox: AsyncSandbox):
await async_sandbox.kill()
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_timeout.py b/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
index 15205a77e..452f2a40c 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
@@ -7,7 +7,7 @@ from e2b import AsyncSandbox
@pytest.mark.skip_debug()
async def test_shorten_timeout(async_sandbox: AsyncSandbox):
await async_sandbox.set_timeout(5)
sleep(6)
@@ -16,7 +16,7 @@ async def test_shorten_timeout(async_sandbox: AsyncSandbox):
@pytest.mark.skip_debug()
async def test_shorten_then_lengthen_timeout(async_sandbox: AsyncSandbox):
await async_sandbox.set_timeout(5)
sleep(1)
diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.py
index 1aef2082a..7de27aa39 100644
--- a/packages/python-sdk/tests/conftest.py
+++ b/packages/python-sdk/tests/conftest.py
@@ -1,4 +1,5 @@
import pytest
+import pytest_asyncio
import os
from logging import warning
@@ -27,7 +28,7 @@ def sandbox(template, debug):
)
+@pytest_asyncio.fixture
async def async_sandbox(template, debug):
sandbox = await AsyncSandbox.create(template)
@@ -53,8 +54,3 @@ def skip_by_debug(request, debug):
if request.node.get_closest_marker("skip_debug"):
if debug:
pytest.skip("skipped because E2B_DEBUG is set")
-
-
-def anyio_backend():
- return "asyncio"