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

Jobs deleted when modifying if ProcessPoolExecuter is default executer #672

Open
3 tasks done
alenzo-pinc opened this issue Oct 26, 2022 · 0 comments
Open
3 tasks done
Labels

Comments

@alenzo-pinc
Copy link

alenzo-pinc commented Oct 26, 2022

Things to check first

  • I have checked that my issue does not already have a solution in the FAQ

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Version

3.9.1

What happened?

When calling BackgroundScheduler.modify_job() when a ProcessPoolExecuter has been set as the default, jobs are removed from the job-store after entering the _jobstores_lock context manager on line 486. This results in a job not found exception.

We have just migrated from a ThreadPoolExecuter and our tests started failing. Found this issue in vscode debugger. Issue is resolved when ThreadPoolExecuter is set as defualt.

setup:

        executors = {
            "default": ProcessPoolExecutor(max_workers=scheduler_settings.workers),
            # "default": ThreadPoolExecutor(max_workers=scheduler_settings.workers),
        }
        self.sched = BackgroundScheduler(executors=executors)

debug output:
image

image

How can we reproduce the bug?

Set default executer to ProcessPoolExecuter and modify a job which exists in the default job store.

from datetime import datetime
from unittest.mock import MagicMock

from apscheduler.executors.pool import ProcessPoolExecutor, ThreadPoolExecutor
from apscheduler.schedulers.background import BackgroundScheduler

executors = {
    "default": ProcessPoolExecutor(max_workers=10),  # THIS DOESN'T WORK
    # "default": ThreadPoolExecutor(max_workers=scheduler_settings.workers), # THIS WORKS
}

sched = BackgroundScheduler(executors=executors)
sched.start()


sched.add_job(print, args=["hi"], id="test")
sched.modify_job("test", next_run_time=datetime.now())  # This throws JobLookupError


image

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

1 participant