Skip to main content

Tạo schedule chạy theo lịch

Project description

Thư viên Schedule trên ngôn ngữ Python để chạy service background.

Copyright: MobioVN

CHANGE LOG:

v0.6.7

  • Sửa lỗi key "last_run"

Cài đặt:

$ pip3 install m-schedule

Sử dụng:

  1. Tạo class thực thi scheduler kế thừa từ class BaseScheduler

    class TestScheduler(BaseScheduler):
        def owner_do(self):
            # TODO
            pass
    
        def get_schedule(self):
            """
            hàm xác định thời điểm chạy của scheduler, bằng cách xử dụng thư viện schedule
            Các ví dụ hướng dẫn cách xác định thời gian chạy
            1. scheduler chỉ thực hiện công việc một lần duy nhất.
                return None
            2. scheduler sẽ thực hiện mỗi 10 phút một lần.
                return schedule.every(10).minutes
            3. scheduler sẽ thực hiện hàng ngày vào lúc 10h 30 phút.
                return schedule.every().day.at("10:30")
            4. scheduler sẽ thực hiện sau mỗi giờ.
                return schedule.every().hour
            5. scheduler sẽ thực hiện vào mỗi thứ 2 hàng tuần.
                return schedule.every().monday
            6. scheduler sẽ thực hiện vào mỗi thứ 5 hàng tuần và vào lúc 13h 15'.
                return schedule.every().wednesday.at("13:15")
            """
        return schedule.every(10).minutes
    
  2. Đăng ký scheduler với factory

    factory = SchedulerFactory()
    factory.add(TestScheduler(name="MyScheduler", redis_uri="redis://redis-server:6379/0"))
    factory.run()
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

m-schedule-0.6.7.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

m_schedule-0.6.7-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file m-schedule-0.6.7.tar.gz.

File metadata

  • Download URL: m-schedule-0.6.7.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for m-schedule-0.6.7.tar.gz
Algorithm Hash digest
SHA256 6957c0647e37d8818cb7ff7745472d93214335d5c35cfbf47684c4f630627b20
MD5 1e77e7fc86683b71b53ccca2be882200
BLAKE2b-256 9e40a5219a082ef25fce951c5aab7e91183f0e3d84a432c08ecf2ceccf87fad5

See more details on using hashes here.

File details

Details for the file m_schedule-0.6.7-py3-none-any.whl.

File metadata

  • Download URL: m_schedule-0.6.7-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for m_schedule-0.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3de713da223b675550bf8e12e72c9389725fe93b9b0bd0ae2f1e896af0eb8b75
MD5 76842093da2fc8bf2935f1511f45c6e7
BLAKE2b-256 31f2b7b82561c7deaed1b7c60d144da0a34d15493071f08bcff3b3c88761e8d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page