Created
June 19, 2022 10:53
-
-
Save syogaraj/cd7e6a0b89bbd8b464260d710695f717 to your computer and use it in GitHub Desktop.
ScheduledThreadPoolExecutor usage
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
from scheduled_thread_pool_executor import ScheduledThreadPoolExecutor | |
scheduled_executor = ScheduledThreadPoolExecutor(max_workers=5) | |
scheduled_executor.schedule(task, 0) # equals to schedule once, where task is a callable | |
scheduled_executor.schedule_at_fixed_rate(task, 0, 5) # schedule immediately and run periodically for every 5 secs | |
scheduled_executor.schedule_at_fixed_delay(task, 5, 10) # schedule after 5secs (initial delay) and run periodically for every 10secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment