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

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.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

m_schedule-0.6.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: m-schedule-0.6.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for m-schedule-0.6.3.tar.gz
Algorithm Hash digest
SHA256 7702ddda9acb6e4226b27dfddca2374e60be19af0621c72bfcfb3eb7f4829f90
MD5 5886f2df77b71ab5f9216749fbdb7786
BLAKE2b-256 11d6e201b57665232953acf1e4d8f84db504999085fa95e260c1e3bc88f8f3dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: m_schedule-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for m_schedule-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9487345ead9ba800eaa0824460512cc93c92f02865c486d6dfd20e470f6f1a2c
MD5 96114393405aa6f2679a06044d69f272
BLAKE2b-256 f778593f2bc753ccebe43bfc1d74694334501dd15fdc44d01a37b1cbad6f668f

See more details on using hashes here.

Supported by

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