Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill or modify a schedule task #32

Closed
pawnies20 opened this issue Jan 5, 2015 · 7 comments
Closed

Kill or modify a schedule task #32

pawnies20 opened this issue Jan 5, 2015 · 7 comments

Comments

@pawnies20
Copy link

Hi and thank for your work: greatfull

Can you explain me how to kill, or modify a Schedule task?

Thank you

@dbader
Copy link
Owner

dbader commented Jan 7, 2015

Hi @pawnies20. I'm not exactly sure what you mean by "kill or modify a schedule task" -- could you elaborate a bit more on what you want to achieve? Thanks.

@robomotic
Copy link

I did like this:

   print ("Starting log...")
   schedule.every(20).minutes.do(get_weather_predictions)

   while 1:
      try:
         schedule.run_pending()
         time.sleep(2)
      except KeyboardInterrupt:
         print("Stopping scheduler")
         schedule.clear()
         print("Closing log")
         writer.close()
         break

@pawnies20
Copy link
Author

Thank you, perfect !!!
A little question:
is it possible to cancel a specific schedule task?

Thank you very much
fred

 Le Vendredi 9 janvier 2015 12h52, Dr. Di Prodi <notifications@github.com> a écrit :

I did like this: print ("Starting log...")
schedule.every(20).minutes.do(get_weather_predictions)

while 1:
try:
schedule.run_pending()
time.sleep(2)
except KeyboardInterrupt:
print("Stopping scheduler")
schedule.clear()
print("Closing log")
writer.close()
break

Reply to this email directly or view it on GitHub.

@pawnies20
Copy link
Author

Schedule.clear() works well, many thanx
But if i want to canceled a specific job what can i do?
schedule.cancel_job() or by returning schedule.CancelJob   seems don't work with me?
Thank you

Fred

 Le Vendredi 9 janvier 2015 14h41, severine fred <severine.fred@yahoo.fr> a écrit :

Thank you, perfect !!!
A little question:
is it possible to cancel a specific schedule task?

Thank you very much
fred

 Le Vendredi 9 janvier 2015 12h52, Dr. Di Prodi <notifications@github.com> a écrit :

I did like this: print ("Starting log...")
schedule.every(20).minutes.do(get_weather_predictions)

while 1:
try:
schedule.run_pending()
time.sleep(2)
except KeyboardInterrupt:
print("Stopping scheduler")
schedule.clear()
print("Closing log")
writer.close()
break

Reply to this email directly or view it on GitHub.

@pawnies20
Copy link
Author

to dbader:

I only want to canceled a specific Schedule task.
Robomotic solution works fine but delete all active tasks

"Hi @pawnies20. I'm not exactly sure what you mean by "kill or modify a schedule task" -- could you elaborate a bit more on what you want to achieve? Thanks."

@pawnies20
Copy link
Author

Please, help me !!!
Thanx

@dbader
Copy link
Owner

dbader commented Feb 12, 2015

Hi @pawnies20 ,

you could do something like this:

def job_that_executes_once():
    # Do some work ...
    return schedule.CancelJob

schedule.today.at('10:30').do(job_that_executes_once)

Basically you let the job cancel itself the first time it executes.

(Linking this to #33 and #35)

@dbader dbader closed this as completed Feb 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants