I'm using apscheduler to arrange some jobs. Some of the jobs have return values after the job be executed. How can I get the return values from these jobs ? Does anyone has idea on this ? Thanks very much.
The feature is still under development, but you can use global variables for now. Here's an example:
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
def fn():
'''Increase `times` by one and print it.'''
global times
times += 1
print(times)
sched = BlockingScheduler()
times = 0
# Execute fn() each second.
sched.add_job(fn, trigger=CronTrigger(second='*/1'))
sched.start()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With