Robert Phan
Robert Phan

Reputation: 1

AsyncIOScheduler Job Stuck in Running State and Never Completes

I have defined a job as follows:

# schedule.py
def start_schedule(config_name):
    async_scheduler = AsyncIOScheduler(
        executors={"default": AsyncIOExecutor()}
    )

    async_scheduler.add_job(
        func=get_images_job,
        trigger=CronTrigger(hour=8, minute=50),
        id='get_cst_img',
        name='Get Image'
    )
    async_scheduler.start()

I used start_schedule function as follows:

# main.py
start_schedule(app_config)

app = FastAPI(prefix='/', lifespan=lifespan)

app.include_router(actuator_router)

However, when it is scheduled to run, it gets stuck and only logs the following:

[2024-11-29 08:50:00.001] INFO apscheduler.executors.default:run_coroutine_job: Running job "Get Image (trigger: cron[hour='8', minute='50'], next run at: 2024-11-30 08:50:00 +07)" (scheduled at 2024-11-29 08:50:00+07:00)

In addition, no logs from the get_images_job function are displayed.

This issue only occurs in the Live environment and is not encountered in the Dev or Local environments. I cannot reproduce this issue in the Dev or Local environments.

Upvotes: 0

Views: 35

Answers (0)

Related Questions