From e3cee02c1d51a6092b1e2c8f809c0af89650d19d Mon Sep 17 00:00:00 2001 From: Bastien Chatelard Date: Tue, 19 May 2026 16:35:18 +0200 Subject: [PATCH 1/3] Fix async files operations The bug: SandboxFilesystem.upload_file calls self.write_file() and download_file calls self.read_file(). When these sync methods run in the executor thread via async_wrapper, self is the AsyncSandboxFilesystem instance, so self.write_file() dispatches to the async override and returns an unawaited coroutine. The fix: call SandboxFilesystem.write_file(self, ...) and SandboxFilesystem.read_file(self, ...) explicitly so the sync methods always invoke the sync implementations, regardless of which subclass self is. --- koyeb/sandbox/filesystem.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/koyeb/sandbox/filesystem.py b/koyeb/sandbox/filesystem.py index 25998044..b4cf0fa6 100644 --- a/koyeb/sandbox/filesystem.py +++ b/koyeb/sandbox/filesystem.py @@ -308,7 +308,7 @@ def write_files(self, files: List[Dict[str, str]]) -> None: path = file_info["path"] content = file_info["content"] encoding = file_info.get("encoding", "utf-8") - self.write_file(path, content, encoding) + SandboxFilesystem.write_file(self, path, content, encoding) def exists(self, path: str) -> bool: """Check if file/directory exists synchronously""" @@ -352,7 +352,7 @@ def upload_file( with open(local_path, "rb") as f: content_bytes = f.read() - self.write_file(remote_path, content_bytes, encoding=encoding) + SandboxFilesystem.write_file(self, remote_path, content_bytes, encoding=encoding) def download_file( self, remote_path: str, local_path: str, encoding: str = "utf-8" @@ -368,7 +368,7 @@ def download_file( Raises: SandboxFileNotFoundError: If remote file doesn't exist """ - file_info = self.read_file(remote_path, encoding=encoding) + file_info = SandboxFilesystem.read_file(self, remote_path, encoding=encoding) if isinstance(file_info.content, bytes): content_bytes = file_info.content @@ -388,7 +388,7 @@ def ls(self, path: str = ".") -> List[str]: Returns: List of file/directory names """ - return self.list_dir(path) + return SandboxFilesystem.list_dir(self, path) def rm(self, path: str, recursive: bool = False) -> None: """ From b33322cd4066b177ad0aa0dcbcaf4d1ba6da904f Mon Sep 17 00:00:00 2001 From: Bastien Chatelard Date: Tue, 19 May 2026 17:13:50 +0200 Subject: [PATCH 2/3] Fix async examples --- examples/00_run_all_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/00_run_all_async.py b/examples/00_run_all_async.py index 7e664cbb..a5c26f75 100644 --- a/examples/00_run_all_async.py +++ b/examples/00_run_all_async.py @@ -198,7 +198,7 @@ async def main(): for example_file in example_files: example_name = example_file.name timeout = flow_timeouts.get(example_name, args.timeout) - result = await run_example(example_file, timeout, suffix) + result = await run_example(example_file, timeout) results.append(result) # Break on error From c79e80eb3bc4a05426da6b751acec81b0707d8f5 Mon Sep 17 00:00:00 2001 From: Bastien Chatelard Date: Tue, 19 May 2026 17:14:00 +0200 Subject: [PATCH 3/3] Fix missing import --- examples/03_basic_commands_async.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/03_basic_commands_async.py b/examples/03_basic_commands_async.py index adb45214..f2360d3e 100644 --- a/examples/03_basic_commands_async.py +++ b/examples/03_basic_commands_async.py @@ -3,6 +3,7 @@ import asyncio import os +import sys import random