ccproxy.scheduler.core¶
ccproxy.scheduler.core
¶
Core scheduler for managing periodic tasks.
Scheduler
¶
Scheduler for managing multiple periodic tasks.
Provides centralized management of scheduled tasks with: - Dynamic task registration and configuration - Graceful startup and shutdown - Task monitoring and status reporting - Error handling and recovery
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_concurrent_tasks
|
int
|
Maximum number of tasks to run concurrently |
10
|
graceful_shutdown_timeout
|
float
|
Timeout for graceful shutdown in seconds |
30.0
|
task_registry
|
TaskRegistry | None
|
Task registry instance (uses global if None) |
None
|
Source code in ccproxy/scheduler/core.py
start
async
¶
Start the scheduler and all enabled tasks.
Source code in ccproxy/scheduler/core.py
stop
async
¶
Stop the scheduler and all running tasks.
Source code in ccproxy/scheduler/core.py
add_task
async
¶
Add and start a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name
|
str
|
Unique name for this task instance |
required |
task_type
|
str
|
Type of task (must be registered in task registry) |
required |
**task_kwargs
|
Any
|
Additional arguments to pass to task constructor |
{}
|
Raises:
Type | Description |
---|---|
TaskRegistrationError
|
If task type is not registered |
SchedulerError
|
If task name already exists or task creation fails |
Source code in ccproxy/scheduler/core.py
remove_task
async
¶
Remove and stop a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name
|
str
|
Name of task to remove |
required |
Raises:
Type | Description |
---|---|
TaskNotFoundError
|
If task does not exist |
Source code in ccproxy/scheduler/core.py
get_task
¶
Get a task instance by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name
|
str
|
Name of task to retrieve |
required |
Returns:
Type | Description |
---|---|
BaseScheduledTask
|
Task instance |
Raises:
Type | Description |
---|---|
TaskNotFoundError
|
If task does not exist |
Source code in ccproxy/scheduler/core.py
list_tasks
¶
get_task_status
¶
Get status information for a specific task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name
|
str
|
Name of task |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Task status dictionary |
Raises:
Type | Description |
---|---|
TaskNotFoundError
|
If task does not exist |
Source code in ccproxy/scheduler/core.py
get_scheduler_status
¶
Get overall scheduler status information.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Scheduler status dictionary |
Source code in ccproxy/scheduler/core.py
get_scheduler
async
¶
Get or create the global scheduler instance.
Returns:
Type | Description |
---|---|
Scheduler
|
Global Scheduler instance |