summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2018-12-05 20:20:15 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2018-12-05 20:20:37 +0200
commiteaf8dbd587b3db0094d5c57c1ef3892811e71150 (patch)
treec38c5b7ad6fe2e440ad4d2290c0fba4f73aa5628
parent108d10c55ec9143ec180db2a06169df911c50bce (diff)
downloadapscheduler-eaf8dbd587b3db0094d5c57c1ef3892811e71150.tar.gz
Adapted RedisJobStore to use the redis 3.0+ library
-rw-r--r--apscheduler/jobstores/redis.py12
-rw-r--r--docs/versionhistory.rst6
-rw-r--r--setup.py2
3 files changed, 15 insertions, 5 deletions
diff --git a/apscheduler/jobstores/redis.py b/apscheduler/jobstores/redis.py
index 61f913e..5bb69d6 100644
--- a/apscheduler/jobstores/redis.py
+++ b/apscheduler/jobstores/redis.py
@@ -14,7 +14,7 @@ except ImportError: # pragma: nocover
import pickle
try:
- from redis import StrictRedis
+ from redis import Redis
except ImportError: # pragma: nocover
raise ImportError('RedisJobStore requires redis installed')
@@ -47,7 +47,7 @@ class RedisJobStore(BaseJobStore):
self.pickle_protocol = pickle_protocol
self.jobs_key = jobs_key
self.run_times_key = run_times_key
- self.redis = StrictRedis(db=int(db), **connect_args)
+ self.redis = Redis(db=int(db), **connect_args)
def lookup_job(self, job_id):
job_state = self.redis.hget(self.jobs_key, job_id)
@@ -81,7 +81,9 @@ class RedisJobStore(BaseJobStore):
pipe.hset(self.jobs_key, job.id, pickle.dumps(job.__getstate__(),
self.pickle_protocol))
if job.next_run_time:
- pipe.zadd(self.run_times_key, datetime_to_utc_timestamp(job.next_run_time), job.id)
+ pipe.zadd(self.run_times_key,
+ {job.id: datetime_to_utc_timestamp(job.next_run_time)})
+
pipe.execute()
def update_job(self, job):
@@ -92,9 +94,11 @@ class RedisJobStore(BaseJobStore):
pipe.hset(self.jobs_key, job.id, pickle.dumps(job.__getstate__(),
self.pickle_protocol))
if job.next_run_time:
- pipe.zadd(self.run_times_key, datetime_to_utc_timestamp(job.next_run_time), job.id)
+ pipe.zadd(self.run_times_key,
+ {job.id: datetime_to_utc_timestamp(job.next_run_time)})
else:
pipe.zrem(self.run_times_key, job.id)
+
pipe.execute()
def remove_job(self, job_id):
diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst
index ce4e862..7f0e0a9 100644
--- a/docs/versionhistory.rst
+++ b/docs/versionhistory.rst
@@ -4,6 +4,12 @@ Version history
To find out how to migrate your application from a previous version of
APScheduler, see the :doc:`migration section <migration>`.
+UNRELEASED
+----------
+
+* Adapted ``RedisJobStore`` to v3.0 of the ``redis`` library
+
+
3.5.3
-----
diff --git a/setup.py b/setup.py
index 5d3a686..92b8da7 100644
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@ setup(
'asyncio:python_version == "2.7"': ['trollius'],
'gevent': ['gevent'],
'mongodb': ['pymongo >= 2.8'],
- 'redis': ['redis'],
+ 'redis': ['redis >= 3.0'],
'rethinkdb': ['rethinkdb'],
'sqlalchemy': ['sqlalchemy >= 0.8'],
'tornado': ['tornado >= 4.3'],