Skip to content

Commit

Permalink
try - multiple workers one instance
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Oct 23, 2023
1 parent 36c5590 commit 5bf5276
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions home/schedulers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django_apscheduler.jobstores import DjangoJobStore, register_events
from apscheduler.schedulers.background import BackgroundScheduler
from .utils.django_email_server import __send__rebate__email__
import sys, socket

def start():
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("127.0.0.1", 47200))
except socket.error:
print, "!!!scheduler already started, DO NOTHING"
else:
scheduler = BackgroundScheduler()
scheduler.add_jobstore(DjangoJobStore(), "default")
scheduler.add_job(__send__rebate__email__, 'cron', hour=23, minute=59, second=0)
register_events(scheduler)
scheduler.start()
scheduler.start()
print, "scheduler started"

0 comments on commit 5bf5276

Please sign in to comment.