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

TimeoutException doesn't have a type to check what kind of timeout it was #463

Open
antonioalegria opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@antonioalegria
Copy link

Describe the bug
There are different types of timeout errors when running code. As described in the TimeoutException class:

class TimeoutException(SandboxException):
    """
    Raised when a timeout occurs.

    The [unavailable] exception type is caused by sandbox timeout.\n
    The [canceled] exception type is caused by exceeding request timeout.\n
    The [deadline_exceeded] exception type is caused by exceeding the timeout for process, watch, etc.\n
    The [unknown] exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.\n
    """

However, when catching one of these exceptions you have to parse the message to infer which of these it is. This is error-prone as you evolve the E2B SDK.

I need a way to check what kind of timeout to then decide what to do with it.

Currently, a sandbox Idle timeout message is:

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.27.0</center>
</body>
</html>
: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout.

While an execution timeout is "Execution timed out — the 'timeout' option can be used to increase this timeout"

To Reproduce
Steps to reproduce the behavior:

Set very short timeouts of the different kinds and see the TimeoutExceptions being thrown.

Expected behavior
A clear and concise description of what you expected to happen.

Should either raise different TimeoutException sub-classes, or the SandboxExceptions should have fields to make it easy to identify exactly what the issue was so the client can handle it properly without having to parse the message.

Additional context

E2B Py SDK v1.01

@antonioalegria antonioalegria added the bug Something isn't working label Oct 24, 2024
Copy link

linear bot commented Oct 24, 2024

@ValentaTomas
Copy link
Member

Hey @antonioalegria, we will be improving the timeout exceptions and adding more granular ones.

@antonioalegria
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants