modal.exception
Modal-specific exception types.
Notes on grpclib.GRPCError migration
Historically, the Modal SDK could propagate grpclib.GRPCError exceptions out
to user code. As of v1.3, we are in the process of gracefully migrating to
always raising a Modal exception type in these cases. To avoid breaking user
code that relies on catching grpclib.GRPCError, a subset of Modal exception
types temporarily inherit from grpclib.GRPCError.
We encourage users to migrate any code that currently catches grpclib.GRPCError to instead catch the appropriate Modal exception type. The following mapping
between GRPCError status codes and Modal exception types is currently in use:
modal.exception.AlreadyExistsError
Raised when a resource creation conflicts with an existing resource.
message
status
details
modal.exception.AsyncUsageWarning
Warning emitted when a blocking Modal interface is used in an async context.
modal.exception.AuthError
Raised when a client has missing or invalid authentication.
message
status
details
modal.exception.ClientClosed
modal.exception.ConflictError
Raised when a resource conflict occurs between the request and current system state.
message
status
details
modal.exception.ConnectionError
Raised when an issue occurs while connecting to the Modal servers.
modal.exception.DataLossError
Raised when data is lost or corrupted.
message
status
details
modal.exception.DeprecationError
UserWarning category emitted when a deprecated Modal feature or API is used.
modal.exception.DeserializationError
Raised to provide more context when an error is encountered during deserialization.
modal.exception.ExecTimeoutError
Raised when a container process exceeds its execution duration limit and times out.
modal.exception.ExecutionError
Raised when something unexpected happened during runtime.
modal.exception.FilesystemExecutionError
Raised when an unknown error is thrown during a container filesystem operation.
modal.exception.FunctionTimeoutError
Raised when a Function exceeds its execution duration limit and times out.
modal.exception.InputCancellation
Raised when the current input is cancelled by the task
Intentionally a BaseException instead of an Exception, so it won’t get caught by unspecified user exception clauses that might be used for retries and other control flow.
modal.exception.InteractiveTimeoutError
Raised when interactive frontends time out while trying to connect to a container.
modal.exception.InternalError
Raised when an internal error occurs in the Modal system.
message
status
details
modal.exception.InternalFailure
Retriable internal error.
modal.exception.InvalidError
Raised when user does something invalid.
message
status
details
modal.exception.ModuleNotMountable
modal.exception.MountUploadTimeoutError
Raised when a Mount upload times out.
modal.exception.NotFoundError
Raised when a requested resource was not found.
message
status
details
modal.exception.OutputExpiredError
Raised when the Output exceeds expiration and times out.
modal.exception.PendingDeprecationError
Soon to be deprecated feature. Only used intermittently because of multi-repo concerns.
modal.exception.PermissionDeniedError
Raised when a user does not have permission to perform the requested operation.
message
status
details
modal.exception.RemoteError
Raised when an error occurs on the Modal server.
modal.exception.RequestSizeError
Raised when an operation produces a gRPC request that is rejected by the server for being too large.
modal.exception.ResourceExhaustedError
Raised when a server-side resource has been exhausted, e.g. a quota or rate limit.
message
status
details
modal.exception.SandboxTerminatedError
Raised when a Sandbox is terminated for an internal reason.
modal.exception.SandboxTimeoutError
Raised when a Sandbox exceeds its execution duration limit and times out.
modal.exception.SerializationError
Raised to provide more context when an error is encountered during serialization.
modal.exception.ServerWarning
Warning originating from the Modal server and re-issued in client code.
modal.exception.ServiceError
Raised when an error occurs in basic client/server communication.
message
status
details
modal.exception.TimeoutError
Base class for Modal timeouts.
modal.exception.UnimplementedError
Raised when a requested operation is not implemented or not supported.
message
status
details
modal.exception.VersionError
Raised when the current client version of Modal is unsupported.
modal.exception.VolumeUploadTimeoutError
Raised when a Volume upload times out.
modal.exception.simulate_preemption
Utility for simulating a preemption interrupt after wait_seconds seconds.
The first interrupt is the SIGINT signal. After 30 seconds, a second
interrupt will trigger.
This second interrupt simulates SIGKILL, and should not be caught.
Optionally add between zero and jitter_seconds seconds of additional waiting before first interrupt.
Usage:
See https://modal.com/docs/guide/preemption for more details on preemption handling.