TimeoutException doesn't have a `type` to check what kind of timeout it was
@mishushakov is already working on this.
Since May 10, 2025.
- Dominant language
- Python
- Stars
- 13.9k
- Forks
- 1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 70
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.