Skip to content

Instantly share code, notes, and snippets.

@syogaraj
Created June 19, 2022 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syogaraj/cd7e6a0b89bbd8b464260d710695f717 to your computer and use it in GitHub Desktop.
Save syogaraj/cd7e6a0b89bbd8b464260d710695f717 to your computer and use it in GitHub Desktop.
ScheduledThreadPoolExecutor usage
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