Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler goes idle or does not execute jobs at all #181

Open
RJ-Gamer opened this issue Mar 22, 2023 · 1 comment
Open

Scheduler goes idle or does not execute jobs at all #181

RJ-Gamer opened this issue Mar 22, 2023 · 1 comment
Labels

Comments

@RJ-Gamer
Copy link

I'm using this library for my project. I wanted to execute few jobs at a specific time. For example:

# time at which task should run
auto_denied_at = appointment_at + timedelta(minutes=constants.APPT_AUTO_DENIED_TIME) # lets say 10 min

And here is my task

def auto_denied_appointment(appointment_id, self=None):
    '''
    automatically change the state of the appointment
    '''
    appointment = Appointment.objects.filter(
        id=appointment_id).values("id", "status", "doctor_detail__user__id", "patient_detail__user__id").first()
    if appointment["status"] in ["REQUESTED", "RESCHEDULE_REQUEST"]:
        Appointment.objects.filter(id=appointment_id).update(status="AUTO_DENIED")
        message = constants.MSG_APPT_DENIED
        params = "{" + "\"appointment_id\": {}".format(appointment['id']) + "}"
        send_notification(
            user_id=appointment["doctor_detail__user__id"],
            params=params,
            message=message,
            notification_type="AUTO_CANCELLED",
        )
        send_notification(
            user_id=appointment["patient_detail__user__id"],
            params=params,
            message=message,
            notification_type="AUTO_CANCELLED",
        )

here is the code for add job

scheduler.add_job(
                func=auto_denied_appointment,
                trigger=DateTrigger(run_date=auto_denied_at),
                args=[appointment_data.id],
                replace_existing=True,
                jobstore="default",
                id=str(appointment_data.id) + '_auto_denied_appointment',
                misfire_grace_time=None,
            )

Job should ideally be executed at given time; but when time arrives scheduler do not execute the job or even could not see the logs
I even tried with interval trigger but most of the time jobs were missed.

I have 3 jobs similar to auto_denied_appointment that need to execute at specific time.

@Undertone0809
Copy link

I had the same problem.Did you solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants