Skip to main content

动态的带结果保存的定时任务管理器-DynamicScheduler

安装

pip install dynamic-scheduler

介绍

主要是结合 apscheduler 完成定时任务动态修改定时任务功能、增加定时任务结果缓存功能

test

  1. 运行下方demo
  2. 重新config类,指定数据库schema
  3. 尝试修改数据库表 cron中cron表达式
  4. 验证定时任务是否修改
  5. 查看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()

Metadata

Release files for dynamic-scheduler 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dynamic-scheduler 1.0.2
File Interpreter ABI Platform Actions
dynamic_scheduler-1.0.2-py3-none-any.whl Python 3 none any Details for dynamic_scheduler-1.0.2-py3-none-any.whl

Release files / dynamic_scheduler-1.0.2-py3-none-any.whl

Download URL dynamic_scheduler-1.0.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e72a2dd1ed3de492d4d8297eb9f59da51fb6f425f0824ad23bac43fc591694b7
BLAKE2b-256 checksum
How to use checksums
68ab168404415c29ec01f3b5a8c010d7c48865498a02e97e3ffa3fd0aeba9639
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for dynamic-scheduler 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page