From c3b547f897c70136f5d2be5ec1c35bf3e89a7959 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 10 Oct 2022 13:09:34 +0530 Subject: [PATCH] refactor!: scheduler without external libraries (#18331) --- frappe/utils/scheduler.py | 15 +++++---------- pyproject.toml | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/frappe/utils/scheduler.py b/frappe/utils/scheduler.py index 018f86cea6..9c730eaffa 100755 --- a/frappe/utils/scheduler.py +++ b/frappe/utils/scheduler.py @@ -12,13 +12,10 @@ Events: import os import time -# imports - third party imports -import schedule - # imports - module imports import frappe from frappe.installer import update_site_config -from frappe.utils import get_datetime, get_sites, now_datetime +from frappe.utils import cint, get_datetime, get_sites, now_datetime from frappe.utils.background_jobs import get_jobs DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" @@ -34,16 +31,14 @@ def cprint(*args, **kwargs): def start_scheduler(): - """Run enqueue_events_for_all_sites every 2 minutes (default). + """Run enqueue_events_for_all_sites based on scheduler tick. Specify scheduler_interval in seconds in common_site_config.json""" - schedule.every(frappe.get_conf().scheduler_tick_interval or 60).seconds.do( - enqueue_events_for_all_sites - ) + tick = cint(frappe.get_conf().scheduler_tick_interval) or 60 while True: - schedule.run_pending() - time.sleep(1) + time.sleep(tick) + enqueue_events_for_all_sites() def enqueue_events_for_all_sites(): diff --git a/pyproject.toml b/pyproject.toml index d633a968e7..f232feac37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,6 @@ dependencies = [ "requests~=2.27.1", "rq~=1.10.1", "rsa>=4.1", - "schedule~=1.1.0", "semantic-version~=2.10.0", "sqlparse~=0.4.1", "tenacity~=8.0.1",