- Home
- Skills
- Psincraian
- Myfy
- Tasks Module
tasks-module_skill
- Python
83
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill psincraian/myfy --skill tasks-module- SKILL.md5.7 KB
Overview
This skill provides a TasksModule for SQL-backed background job processing with dependency injection, automatic retries, and progress reporting. It integrates with an application to define async tasks via an @task decorator and dispatch jobs from routes or services. Workers poll the database, execute tasks with DI, and persist results and state.
How this skill works
Register the TasksModule in your application and decorate async functions with @task to make them executable as background jobs. Dispatch uses .send(...) which enqueues a job and returns a task_id; workers poll the DB, run tasks with injected services and TaskContext, handle retries, and store results. Task state, progress, errors, and outputs are available via .get_result(task_id).
When to use it
- Offload long-running work from HTTP requests to avoid blocking responses.
- Schedule retries for flaky external calls (APIs, S3 uploads, etc.).
- Run background processing that needs dependency injection (DB sessions, services).
- Report progress for long import/migration tasks to clients.
- Prioritize or delay work with per-dispatch options (priority, delay).
Best practices
- Make tasks idempotent so retries are safe and side-effects are controlled.
- Serialize only primitives and small collections; load complex objects inside the task using injected services.
- Use TaskContext to report progress and to register cleanup for timeouts or cancellations.
- Configure sensible timeouts and retry policies to avoid stuck workers and repeated failures.
- Monitor worker logs and failed-task traces; use priorities for critical work.
Example use cases
- Send emails or notifications asynchronously after user signup.
- Process file imports with progress updates and final result retrieval.
- Retry flaky API calls with custom retry_on exception lists.
- Run database synchronization tasks using an injected AsyncSession.
- Upload files to external storage with backoff and retry limits.
FAQ
Call task.get_result(task_id). The result object indicates is_completed, is_failed, or is_pending, includes value or error, and exposes progress and progress_message if reported.
How are retries and delays configured?
Defaults come from MYFY_TASKS_ environment variables and task decorator options. Per-dispatch overrides (_max_retries, _delay) are supported when sending a task.