Last active
August 13, 2023 09:42
-
-
Save vanleantking/21400df37ae3b0b94b5ab35cd43bcae8 to your computer and use it in GitHub Desktop.
config parallel workers run on task schedule apscheduler package python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use basic config: | |
from apscheduler.schedulers.background import BackgroundScheduler | |
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor | |
executors = { | |
'default': ThreadPoolExecutor(20), | |
'processpool': ProcessPoolExecutor(5) | |
} | |
job_defaults = { | |
'coalesce': False, | |
'max_instances': 3 | |
} | |
scheduler = BackgroundScheduler(executors=executors, job_defaults=job_defaults) | |
REF: | |
ProcessPoolExecutor runs each of your workers in its own separate child process. | |
ThreadPoolExecutor runs each of your workers in separate threads within the main process. | |
https://stackoverflow.com/questions/51828790/what-is-the-difference-between-processpoolexecutor-and-threadpoolexecutor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment