sankalpjonn / timeloop

An elegant periodic task executor
MIT License
245 stars 49 forks source link

Account for execution time #10

Open ukchukx opened 5 years ago

ukchukx commented 5 years ago

Account for job execution time, so the job can be triggered at uniform intervals. Pass keyword arguments other than interval to the target job.

joac-asapp commented 5 years ago

I will love to have this merged

matfax commented 5 years ago

This PR should also fix #4. @sankalpjonn Do you still intend to maintain this project?

Poseideon commented 4 years ago

@ukchukx , I was using your commits and wanted to know how to setup the job with arguments. Can you please share an example how I could decorate below function that accepted parameters -

@tl.job(interval=timedelta(seconds=2)) def sample_job_every_Ns(nseconds): print "{}s job current time : {}".format(nseconds, time.ctime())

Thanks!

ukchukx commented 4 years ago

@Poseideon Maybe this could help:

@tl.job(interval=timedelta(seconds=10), this='that', that='this', other=1)
def todo(this, that, other):
  print(this, that, other)
stephan1827 commented 3 years ago

@Poseideon Maybe this could help:

@tl.job(interval=timedelta(seconds=10), this='that', that='this', other=1)
def todo(this, that, other):
  print(this, that, other)

I tried the changes but when I try to pass arguments I get

Exception has occurred: TypeError job() got an unexpected keyword argument 'this'

The error message makes sense because job still only expects interval as parameter. Do I miss something here?

Stephan