diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2016-07-16 16:25:18 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2016-07-16 16:25:18 +0300 |
commit | a6bdea38975667e7f3ca61c97f6877c24da3f00d (patch) | |
tree | 9aa98769753f5e9cefa93797b39ed45d52f6e333 | |
parent | 3c47d78c98fe4da56d6b0be075c489d7449246fb (diff) | |
download | apscheduler-a6bdea38975667e7f3ca61c97f6877c24da3f00d.tar.gz |
Updated jobstore related documentation and examples
Added missing API documentation pages for rethinkdb and zookeeper job stores.
Also added example script for rethinkdb.
Mentioned RethinkDB in README.
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | docs/modules/jobstores/redis.rst | 2 | ||||
-rw-r--r-- | docs/modules/jobstores/rethinkdb.rst | 25 | ||||
-rw-r--r-- | docs/modules/jobstores/zookeeper.rst | 25 | ||||
-rw-r--r-- | examples/jobstores/rethinkdb_.py | 33 |
5 files changed, 86 insertions, 2 deletions
@@ -29,7 +29,8 @@ Supported backends for storing jobs include: * `SQLAlchemy <http://www.sqlalchemy.org/>`_ (any RDBMS supported by SQLAlchemy works) * `MongoDB <http://www.mongodb.org/>`_ * `Redis <http://redis.io/>`_ -* `Zookeeper <https://zookeeper.apache.org/>`_ +* `RethinkDB <https://www.rethinkdb.com/>`_ +* `ZooKeeper <https://zookeeper.apache.org/>`_ APScheduler also integrates with several common Python frameworks, like: diff --git a/docs/modules/jobstores/redis.rst b/docs/modules/jobstores/redis.rst index e016c44..8d7f833 100644 --- a/docs/modules/jobstores/redis.rst +++ b/docs/modules/jobstores/redis.rst @@ -1,5 +1,5 @@ :mod:`apscheduler.jobstores.redis` -======================================== +================================== .. automodule:: apscheduler.jobstores.redis diff --git a/docs/modules/jobstores/rethinkdb.rst b/docs/modules/jobstores/rethinkdb.rst new file mode 100644 index 0000000..e43ebf4 --- /dev/null +++ b/docs/modules/jobstores/rethinkdb.rst @@ -0,0 +1,25 @@ +:mod:`apscheduler.jobstores.rethinkdb` +====================================== + +.. automodule:: apscheduler.jobstores.rethinkdb + +API +--- + +.. autoclass:: RethinkDBJobStore(database='apscheduler', table='jobs', client=None, pickle_protocol=pickle.HIGHEST_PROTOCOL, **connect_args) + :show-inheritance: + + +Introduction +------------ + +RethinkDBJobStore stores jobs in a `RethinkDB <https://www.rethinkdb.com/>`_ database. + +.. list-table:: + :widths: 1 4 + + * - External dependencies + - `rethinkdb <https://pypi.python.org/pypi/rethinkdb>`_ + * - Example + - ``examples/jobstores/rethinkdb_.py`` + (`view online <https://github.com/agronholm/apscheduler/tree/master/examples/jobstores/rethinkdb_.py>`_). diff --git a/docs/modules/jobstores/zookeeper.rst b/docs/modules/jobstores/zookeeper.rst new file mode 100644 index 0000000..9dfa389 --- /dev/null +++ b/docs/modules/jobstores/zookeeper.rst @@ -0,0 +1,25 @@ +:mod:`apscheduler.jobstores.zookeeper` +====================================== + +.. automodule:: apscheduler.jobstores.zookeeper + +API +--- + +.. autoclass:: ZooKeeperJobStore(path='/apscheduler', client=None, close_connection_on_exit=False, pickle_protocol=pickle.HIGHEST_PROTOCOL, **connect_args) + :show-inheritance: + + +Introduction +------------ + +ZooKeeperJobStore stores jobs in an `Apache ZooKeeper <https://zookeeper.apache.org/>`_ instance. + +.. list-table:: + :widths: 1 4 + + * - External dependencies + - `kazoo <https://pypi.python.org/pypi/kazoo>`_ + * - Example + - ``examples/jobstores/zookeeper.py`` + (`view online <https://github.com/agronholm/apscheduler/tree/master/examples/jobstores/zookeeper.py>`_). diff --git a/examples/jobstores/rethinkdb_.py b/examples/jobstores/rethinkdb_.py new file mode 100644 index 0000000..c1baa0e --- /dev/null +++ b/examples/jobstores/rethinkdb_.py @@ -0,0 +1,33 @@ +""" +This example demonstrates the use of the RethinkDB job store. +On each run, it adds a new alarm that fires after ten seconds. +You can exit the program, restart it and observe that any previous alarms that have not fired yet +are still active. Running the example with the --clear switch will remove any existing alarms. +""" + +from datetime import datetime, timedelta +import sys +import os + +from apscheduler.schedulers.blocking import BlockingScheduler + + +def alarm(time): + print('Alarm! This alarm was scheduled at %s.' % time) + + +if __name__ == '__main__': + scheduler = BlockingScheduler() + scheduler.add_jobstore('rethinkdb', database='apscheduler_example') + if len(sys.argv) > 1 and sys.argv[1] == '--clear': + scheduler.remove_all_jobs() + + alarm_time = datetime.now() + timedelta(seconds=10) + scheduler.add_job(alarm, 'date', run_date=alarm_time, args=[datetime.now()]) + print('To clear the alarms, run this example with the --clear argument.') + print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C')) + + try: + scheduler.start() + except (KeyboardInterrupt, SystemExit): + pass |