* added a synchronous cluster simulation

* added a test for the sync function

* moved signing into its own module

* refactored imports to solve circular import problems stemming from the task module pretending to be a cluster

* added documentation for the new sync option
This commit is contained in:
Ilan Steemers
2015-07-09 20:16:21 +02:00
parent 31dbd29b36
commit e62fd1ee70
7 changed files with 124 additions and 56 deletions
+4 -5
View File
@@ -4,13 +4,12 @@ import socket
from blessed import Terminal
# django
from django.core import signing
from django.utils import timezone
from django.utils.translation import ugettext as _
# local
import signing
from django_q.conf import Conf, redis_client, logger
from django_q.tasks import SignedPackage
def monitor(run_once=False):
@@ -147,7 +146,7 @@ class Stat(Status):
def save(self):
try:
self.r.set(self.key, SignedPackage.dumps(self, True), 3)
self.r.set(self.key, signing.SignedPackage.dumps(self, True), 3)
except Exception as e:
logger.error(e)
@@ -165,7 +164,7 @@ class Stat(Status):
if r.exists(key):
pack = r.get(key)
try:
return SignedPackage.loads(pack)
return signing.SignedPackage.loads(pack)
except signing.BadSignature:
return None
return Status(cluster_id)
@@ -182,7 +181,7 @@ class Stat(Status):
packs = r.mget(keys)
for pack in packs:
try:
stats.append(SignedPackage.loads(pack))
stats.append(signing.SignedPackage.loads(pack))
except signing.BadSignature:
continue
return stats