从包装函数添加时,APscheduler不会执行作业

时间:2016-01-15 23:04:38

标签: python regex apscheduler

def print_hello(what):
 print 'Remind working'
 print what

def test(sender,kw):
  regex="remind me (to) (?P<reminder_text>.*?) (at|on|in) (?P<remind_time>.*)?"
  m=re.match(regex,kw['text'],re.DOTALL)
  if m:
    what=m.group("reminder_text")
    when=m.group("remind_time")
    when=nt.parse_natural_time(when)
    print when
    SCHEDULER.add_job(print_hello, 'date', name='testme', run_date=when,args=[what])
  SCHEDULER.print_jobs()`

作业会添加到调度程序中,但作业不会运行。

但是当我执行此操作时:

def print_hello(what):
  print 'Remind working'
  print what

def test(sender,kw):
regex="remind me (to) (?P<reminder_text>.*?) (at|on|in) (?P<remind_time>.*)?"
m=re.match(regex,kw['text'],re.DOTALL)
if m:
    what=m.group("reminder_text")
    when=m.group("remind_time")
    when=nt.parse_natural_time(when)
    print when   
SCHEDULER.print_jobs()

SCHEDULER.add_job(print_hello, 'date', name='testme', run_date=when,args=[what])`

作业在那个时刻执行。

0 个答案:

没有答案