From e50aa536c2c8b68d0585fb8ed12e4f2b3f7c9eea Mon Sep 17 00:00:00 2001 From: Eran Sandler Date: Mon, 7 Apr 2014 12:14:10 +0300 Subject: [PATCH] Make sure qr serialization will always be in JSON - in the case we do end up serializing big objects - so that other parts of the system can be written in languages other than Python --- redash/data/manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 redash/data/manager.py diff --git a/redash/data/manager.py b/redash/data/manager.py old mode 100644 new mode 100755 index c5edcdb82..3b63a9cfe --- a/redash/data/manager.py +++ b/redash/data/manager.py @@ -6,17 +6,25 @@ import logging import peewee import qr import redis +import json from redash import models from redash.data import worker from redash.utils import gen_query_hash +class JSONPriorityQueue(qr.PriorityQueue): + """ Use a JSON serializer to help with cross language support """ + def __init__(self, key, **kwargs): + super(qr.PriorityQueue, self).__init__(key, **kwargs) + self.serializer = json + + class Manager(object): def __init__(self, redis_connection, statsd_client): self.statsd_client = statsd_client self.redis_connection = redis_connection self.workers = [] - self.queue = qr.PriorityQueue("jobs", **self.redis_connection.connection_pool.connection_kwargs) + self.queue = JSONPriorityQueue("jobs", **self.redis_connection.connection_pool.connection_kwargs) self.max_retries = 5 self.status = { 'last_refresh_at': 0,