-
Notifications
You must be signed in to change notification settings - Fork 38
Worker improvements #361
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
base: main
Are you sure you want to change the base?
Worker improvements #361
Conversation
|
|
||
|
|
||
| class BackgroundEventLoop: | ||
| """Manages a persistent asyncio event loop running in a background thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a SDK user, given I choose to use the async worker, I should have created my own event loop in my applicaiton instead of expecting the SDK to maintain a loop on behalf of me internally.
Is this a fair assumption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current design creates one thread per worker task (so if you have 5 workers, there will be 5 threads polling/executing). This is consistent with other SDKs like Java. When creating the loop the loop belongs to the thread. This is internal implementation for the SDK. However I can see a future version that supports bringing your own loop.
Worker Configuration, Event-Driven Observability & Metrics
Overview
Introduces event-driven observability with Prometheus metrics, hierarchical worker configuration, runtime pausing, and startup logging.
Key Features
1. Event-Driven Observability
Zero-coupling architecture for metrics and monitoring:
Benefits: Multiple backends (Prometheus, DataDog, custom), protocol-based, non-blocking
2. Built-in Prometheus Metrics
HTTP server with automatic multiprocess aggregation:
Metrics: API latency (p50-p99), task execution time, error rates, queue saturation
3. Worker Configuration
Single-line startup logging + hierarchical env overrides:
4. Runtime Worker Pausing
Environment-only control (no code changes):
5. Async functions can now be used with @worker_task annotations
When a function is marked as async, they are executed using background asyncio event loop.
Related Documentation