【问题标题】:APScheduler doesnt save jobs into mongodb databaseAPScheduler 不会将作业保存到 mongodb 数据库中
【发布时间】:2020-04-26 14:37:26
【问题描述】:

我无法将作业保存到 mongodb 数据库中。

我尝试添加 'url': 'mongodb://localhost/My-db' 到默认的jobstore,但它甚至没有编译。

scheduler = BackgroundScheduler({
    'apscheduler.jobstores.default': {
        'type': 'mongodb'
    },
    'apscheduler.executors.default': {
        'class': 'apscheduler.executors.pool:ThreadPoolExecutor',
        'max_workers': '20'
    },
    'apscheduler.executors.processpool': {
        'type': 'processpool',
        'max_workers': '5'
    },
    'apscheduler.job_defaults.coalesce': 'false',
    'apscheduler.job_defaults.max_instances': '3',
    'apscheduler.timezone': 'UTC',
    })

【问题讨论】:

  • 什么不能编译?你得到一个例外还是什么?请发布更多详细信息。

标签: python mongodb flask apscheduler


【解决方案1】:

所以其实我自己发现的。问题解决了 MongoClient

client = MongoClient('mongo_url')

jobstores = {
    'mongo': MongoDBJobStore(client=client)
}
executors = {
    'default': ThreadPoolExecutor(20),
    'processpool': ProcessPoolExecutor(5)
}
job_defaults = {
    'coalesce': False,
    'max_instances': 3
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    • 1970-01-01
    • 1970-01-01
    • 2019-06-24
    • 2017-07-27
    • 1970-01-01
    • 2011-02-04
    相关资源
    最近更新 更多