用于add_date_job的python apscheduler.scheduler不起作用

时间:2013-12-31 10:33:13

标签: python scheduled-tasks apscheduler

我尝试这样的事情

import requests
from datetime import datetime
from apscheduler.scheduler import Scheduler



url = 'http://example.com?'
headers = {
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}

data = {'simple'='good'}

def my_job():
    r = requests.post(url, data=data, headers=headers)
    print r.text
    print datetime.now()

if __name__ == '__main__':
    scheduler = Scheduler(standalone=True)

    job = scheduler.add_date_job(my_job, '2013-12-31 13:53:27.100000')
    print('Press Ctrl+C to exit')
    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass

我的问题是触发器触发,但是req函数中的print不会显示。似乎无法发送请求。请求函数是健康的,因为尝试它,但它不适用于Scheduler。

0 个答案:

没有答案