0

i have a problem regarding to pythons' apscheduler.

i'm running a task that includes pulling data from db. The dbs' response time varies, because of different operations on it, from different sources, and predicting when the dbs' response time will be low, is not possible.

for example when running

    scheduler.add_interval_job(self.readFromDb, start_date = now(), seconds=60)

The seconds parameter stops the task, if it didn't finish, and starts the next task

is there a way of changing the seconds parameter dynamically? or should i use the default value of 0?

cheers

gCoh
  • 2,719
  • 1
  • 22
  • 46
  • I want to make sure we're on the same page regarding what that line does. It tells the scheduler to add a job that is executed in 60 second intervals, starting now. Is this what you expect? – Alex Grönholm Feb 27 '15 at 11:44
  • yes, and that is fine. the problem is when the job ends after more than 1 minute (it terminates) – gCoh Mar 01 '15 at 09:25

1 Answers1

1

The "seconds" parameter does not in any way limit how long the job can take, and it certainly does not terminate it prematurely. However, it will, with the default settings, prevent another instance of the job from being spawned if the previous instance is taking longer than the specified interval (60 seconds here). The way I see it, you have two options here:

  1. Ignore the fact that a new instance of the task sometimes fails to start
  2. Increase the max_instances parameter from the default of 1 so more than one instance of the task can run concurrently
Alex Grönholm
  • 5,563
  • 29
  • 32