Move signal handler

This commit is contained in:
Alex DeBrie 2015-11-23 14:02:09 +00:00
parent 45a85c110f
commit 5b9b18639b
2 changed files with 5 additions and 6 deletions

View File

@ -1,6 +1,5 @@
import logging
import json
import signal
import jsonschema
from jsonschema import ValidationError
@ -43,15 +42,11 @@ SUPPORTED_COLUMN_TYPES = set([
class InterruptException(Exception):
pass
def signal_handler(*args):
raise InterruptException
class BaseQueryRunner(object):
def __init__(self, configuration):
jsonschema.validate(configuration, self.configuration_schema())
self.syntax = 'sql'
self.configuration = configuration
signal.signal(signal.SIGINT, signal_handler)
@classmethod
def name(cls):

View File

@ -1,5 +1,6 @@
import time
import logging
import signal
from flask.ext.mail import Message
import redis
from celery import Task
@ -8,7 +9,7 @@ from celery.utils.log import get_task_logger
from redash import redis_connection, models, statsd_client, settings, utils, mail
from redash.utils import gen_query_hash
from redash.worker import celery
from redash.query_runner import get_query_runner
from redash.query_runner import get_query_runner, InterruptException
logger = get_task_logger(__name__)
@ -263,9 +264,12 @@ def check_alerts_for_query(self, query_id):
mail.send(message)
def signal_handler(*args):
raise InterruptException
@celery.task(bind=True, base=BaseTask, track_started=True)
def execute_query(self, query, data_source_id, metadata):
signal.signal(signal.SIGINT, signal_handler)
start_time = time.time()
logger.info("Loading data source (%d)...", data_source_id)