modal.exception
modal.exception.AuthError
class AuthError(modal.exception.Error)
Raised when a client has missing or invalid authentication.
modal.exception.ConnectionError
class ConnectionError(modal.exception.Error)
Raised when an issue occurs while connecting to the Modal servers.
modal.exception.DeprecationError
class DeprecationError(UserWarning)
UserWarning category emitted when a deprecated Modal feature or API is used.
modal.exception.ExecutionError
class ExecutionError(modal.exception.Error)
Raised when something unexpected happened during runtime.
modal.exception.FunctionTimeoutError
class FunctionTimeoutError(modal.exception.TimeoutError)
Raised when a Function exceeds its execution duration limit and times out.
modal.exception.InvalidError
class InvalidError(modal.exception.Error)
Raised when user does something invalid.
modal.exception.MountUploadTimeoutError
class MountUploadTimeoutError(modal.exception.TimeoutError)
Raised when a Mount upload times out.
modal.exception.NotFoundError
class NotFoundError(modal.exception.Error)
Raised when a requested resource was not found.
modal.exception.PendingDeprecationError
class PendingDeprecationError(UserWarning)
Soon to be deprecated feature. Only used intermittently because of multi-repo concerns.
modal.exception.RemoteError
class RemoteError(modal.exception.Error)
Raised when an error occurs on the Modal server.
modal.exception.SandboxTerminatedError
class SandboxTerminatedError(modal.exception.Error)
Raised when a Sandbox is terminated for an internal reason.
modal.exception.SandboxTimeoutError
class SandboxTimeoutError(modal.exception.TimeoutError)
Raised when a Sandbox exceeds its execution duration limit and times out.
modal.exception.TimeoutError
class TimeoutError(modal.exception.Error)
Base class for Modal timeouts.
modal.exception.VersionError
class VersionError(modal.exception.Error)
Raised when the current client version of Modal is unsupported.
modal.exception.deprecation_error
def deprecation_error(deprecated_on: date, msg: str):
modal.exception.deprecation_warning
def deprecation_warning(deprecated_on: date, msg: str, pending=False):
Utility for getting the proper stack entry.
See the implementation of the built-in warnings.warn.
modal.exception.simulate_preemption
def simulate_preemption(wait_seconds: int, jitter_seconds: int = 0):
Utility for simulating a preemption interrupt after wait_seconds
seconds.
The first interrupt is the SIGINT/SIGTERM 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:
import time
from modal.exception import simulate_preemption
simulate_preemption(3)
try:
time.sleep(4)
except KeyboardInterrupt:
print("got preempted") # Handle interrupt
raise
See https://modal.com/docs/guide/preemption for more details on preemption handling.