refactor!: scheduler without external libraries (#18331)
This commit is contained in:
parent
4a3259ed92
commit
c3b547f897
2 changed files with 5 additions and 11 deletions
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue