how Advanced Python Scheduler it's works

485 views
Skip to first unread message

yonatan amir

unread,
Nov 9, 2017, 10:36:00 AM11/9/17
to APScheduler
Hi,
i am new with this service and i have some questions and maybe some of you can help.(note that i am using python 2.7)
 from what i understand if i want to run the python script with function that repeat in intervals I should add a job to the scheduler like this( example below)
# Start the scheduler
sched = Scheduler()
sched.daemonic = False
sched.start()

def job_function():
    print("Hello World")
    print(datetime.datetime.now())
    time.sleep(20)

# Schedules job_function to be run once each minute
sched.add_cron_job(job_function,  minute='0-59')
my questions are : 1)how this process works? 
                   2)can i add two jobs that will run simultaneously? for example two bat files
                   3)how can i get the return value for the job? 
                   2) what happens if the computer restart ?the  scheduler  start  again by himself or should i run again the python script?

Alex Grönholm

unread,
Nov 9, 2017, 12:02:51 PM11/9/17
to apsch...@googlegroups.com

Have you read the documentation? I suggest you do so first and then say if you have something you didn't understand.

As for your code, it looks like it was written for APScheduler 2.x or earlier. Look for the "examples" directory in the APScheduler Github project for plenty of working examples that run on the latest version.

--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

yonatan amir

unread,
Nov 10, 2017, 11:17:55 AM11/10/17
to apsch...@googlegroups.com
Hi , yes i read the user guide (https://github.com/agronholm/apscheduler/blob/master/docs/userguide.rst) but i didn't  see any mention to questions 3 and 4 ?
maybe you meant to other documentation ,if so can you send me the link please? 



Sent with Mailtrack

To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "APScheduler" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/apscheduler/_mk8wbrr-Jo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to apscheduler+unsubscribe@googlegroups.com.

Alex Grönholm

unread,
Nov 10, 2017, 11:46:11 AM11/10/17
to apsch...@googlegroups.com

3) You can do this by listening to the appropriate scheduler events. See http://apscheduler.readthedocs.io/en/latest/userguide.html#scheduler-events and http://apscheduler.readthedocs.io/en/latest/modules/events.html#apscheduler.events.JobExecutionEvent . The "retval" attribute on JobExecutionEvent will get you the return value.

4) The scheduler is a part of your application, so unless you've arranged for your application to restart on boot, it won't.

To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.

yonatan amir

unread,
Nov 10, 2017, 12:07:27 PM11/10/17
to apsch...@googlegroups.com
thanks dude 
Reply all
Reply to author
Forward
0 new messages