Quick Start: Factory Functions
Use factory functions for common error handling patterns:| Function | Behavior |
|---|---|
retry_transient() | Retry ConnectionError, TimeoutError, OSError with exponential backoff |
retry_all() | Retry any exception with exponential backoff |
skip_on_error() | Return None for any exception (skip the row) |
fail_fast() | Fail immediately on any exception (default behavior) |
Customizing Retry Behavior
Factory functions accept parameters to customize behavior:max_attempts(int): Maximum number of attempts (default: 3)backoff(str): Backoff strategy between retries"exponential"(default): 1s, 2s, 4s, 8s… with jitter, capped at 60s"fixed": Fixed 1s delay between attempts"linear": 1s, 2s, 3s, 4s… capped at 60s
Custom Exception Handling: Matchers
For fine-grained control, useRetry, Skip, and Fail matchers:
- Matchers are evaluated in order (first match wins)
- More specific matchers should come before general ones
- Unmatched exceptions fail the job
Exception Matchers
| Matcher | Behavior | Parameters |
|---|---|---|
Retry(...) | Retry with backoff, then fail | max_attempts, backoff, match |
Skip(...) | Return None for that row | match |
Fail(...) | Fail the job immediately | match |
Message Matching
Use thematch parameter to filter exceptions by their message content. The pattern is a regex:
Behavior Summary
| Outcome | What Happens | When to Use |
|---|---|---|
| Retry | Retry with backoff, then fail/skip | Transient errors: network issues, rate limits, timeouts |
| Skip | Return None for that row | Bad input data, row-specific failures, optional enrichment |
| Fail | Kill the job immediately | Fatal errors: auth failures, configuration errors |
Advanced: Full Tenacity Control
For power users who need custom callbacks or complex retry conditions, omiton_error and use error_handling=:
on_error= and error_handling= cannot be used together.
Restrictions
- Skip behavior only works with scalar UDFs (functions that process one row at a time)
- For batch UDFs that receive
RecordBatch, useRetryorFailonly - All Retry matchers must use the same backoff strategy. You cannot mix different backoff strategies in the same
on_errorlist:
- Invalid regex patterns are rejected at construction time: