动态的带结果保存的定时任务管理器
Project description
动态的带结果保存的定时任务管理器-DynamicScheduler
安装
pip install dynamic-scheduler
介绍
主要是结合 apscheduler 完成定时任务动态修改定时任务功能、增加定时任务结果缓存功能
test
- 运行下方demo
- 重新config类,指定数据库schema
- 尝试修改数据库表 cron中cron表达式
- 验证定时任务是否修改
- 查看apscheduler_jobs表任务结果
demo
from DynamicScheduler.dynamic_scheduler import DynamicSchedulerProxy
from DynamicScheduler.scheduler_utils import SchedulerConfig
import datetime, os, threading
def task():
# print(datetime.datetime.now())
# time.sleep(10)
print('start time: ', datetime.datetime.now(), os.getpid(), threading.current_thread().name)
return datetime.datetime.now()
class Config(SchedulerConfig):
DEFAULT_DB_URL = 'postgresql+psycopg2://postgres:123456@{your_ip}:5432/postgres?utf-8'
SCHEDULER_SCHEMA = 'public'
s = DynamicSchedulerProxy(config_class=Config)
s.add_job_with_default(func=task, cron_str='* * */5', id='task')
s.clear_history() # 先清除缓存表
s.add_result_listener()
s.start()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file dynamic_scheduler-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: dynamic_scheduler-1.0.2-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e72a2dd1ed3de492d4d8297eb9f59da51fb6f425f0824ad23bac43fc591694b7 |
|
MD5 | bf1873a301f0fa5ed99d85963c421809 |
|
BLAKE2b-256 | 68ab168404415c29ec01f3b5a8c010d7c48865498a02e97e3ffa3fd0aeba9639 |