xiaohongshu
xiaohongshu
erpnext-syntax-scheduler
Scheduler and background jobs syntax for Frappe/ERPNext v14/v15/v16. Use for scheduler_events in hooks.py, frappe.enqueue() for async jobs, queue configuration, job deduplication, error handling, and monitoring. Triggers on questions about scheduled tasks, background processing, cron jobs, RQ wor...
Full skill instructions
Deterministic syntax reference for Frappe scheduler events and background job processing.
# hooks.py
scheduler_events = {
"all": ["myapp.tasks.every_tick"],
"hourly": ["myapp.tasks.hourly_task"],
"daily": ["myapp.tasks.daily_task"],
"weekly": ["myapp.tasks.weekly_task"],
"monthly": ["myapp.tasks.monthly_task"],
"daily_long": ["myapp.tasks.heavy_daily"], # Long queue
"cron": {
"0 9 * * 1-5": ["myapp.tasks.weekday_9am"],
"*/15 * * * *": ["myapp.tasks.every_15_min"]
}
}
CRITICAL: After EVERY change to scheduler_events: bench migrate
# Simple
frappe.enqueue("myapp.tasks.process", customer="CUST-001")
# With queue and timeout
frappe.enqueue(
"myapp.tasks.heavy_task",
queue="long",
timeout=3600,
param="value"
)
# With deduplication (v15)
from frappe.utils.background_jobs import is_job_enqueued
job_id = f"import::{doc.name}"
if not is_job_enqueued(job_id):
frappe.enqueue("myapp.tasks.import_data", job_id=job_id, doc=doc.name)
| Event | Frequency | Queue |
|---|---|---|
all | Every tick (v14: 4min, v15: 60s) | default |
hourly | Per hour | default |
daily | Per day | default |
weekly | Per week | default |
monthly | Per month | default |
hourly_long | Per hour | long |
daily_long | Per day | long |
weekly_long | Per week | long |
monthly_long | Per month | long |
cron | Custom schedule | configurable |
Version difference scheduler tick:
| Queue | Timeout | Usage |
|---|---|---|
short | 300s (5 min) | Quick tasks, UI responses |
default | 300s (5 min) | Standard tasks |
long | 1500s (25 min) | Heavy processing, imports |
frappe.enqueue(
method, # REQUIRED: function or module path
queue="default", # Queue name
timeout=None, # Override timeout (seconds)
is_async=True, # False = execute directly
now=False, # True = via frappe.call()
job_id=None, # v15: unique ID for deduplication
enqueue_after_commit=False, # Wait for DB commit
at_front=False, # Place at front of queue
on_success=None, # Success callback
on_failure=None, # Failure callback
**kwargs # Arguments for method
)
from frappe.utils.background_jobs import is_job_enqueued
job_id = f"process::{doc.name}"
if not is_job_enqueued(job_id):
frappe.enqueue(
"myapp.tasks.process",
job_id=job_id,
doc_name=doc.name
)
# DO NOT USE - only for legacy code
from frappe.core.page.background_jobs.background_jobs import get_info
enqueued = [d.get("job_name") for d in get_info()]
if name not in enqueued:
frappe.enqueue(..., job_name=name)
def process_records(records):
for record in records:
try:
process_single(record)
frappe.db.commit() # Commit per success
except Exception:
frappe.db.rollback() # Rollback on error
frappe.log_error(
frappe.get_traceback(),
f"Process Error: {record}"
)
def on_success_handler(job, connection, result, *args, **kwargs):
frappe.publish_realtime("show_alert", {"message": "Done!"})
def on_failure_handler(job, connection, type, value, traceback):
frappe.log_error(f"Job {job.id} failed: {value}")
frappe.enqueue(
"myapp.tasks.risky_task",
on_success=on_success_handler,
on_failure=on_failure_handler
)
IMPORTANT: Scheduler jobs run as Administrator!
def scheduled_task():
# frappe.session.user = "Administrator"
# Set explicit owner:
doc = frappe.new_doc("ToDo")
doc.owner = "[email protected]"
doc.insert(ignore_permissions=True)
| Tool | Description |
|---|---|
| RQ Worker (DocType) | Worker status, busy/idle |
| RQ Job (DocType) | Job status, queue filter |
bench doctor | Scheduler status overview |
| Scheduled Job Log | Execution history |
| Feature | v14 | v15 |
|---|---|---|
| Tick interval | 4 min | 60 sec |
| Config key | scheduler_interval | scheduler_tick_interval |
| Deduplication | job_name | job_id + is_job_enqueued() |
bench migrate after hooks.py scheduler_events changesjob_id + is_job_enqueued() for deduplication (v15)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience