Hacking rules: H302, H303, H304, H401, H404 Change-Id: I38e62696724a99c5ebe74d95d477999bd91a2c9a
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright (C) 2013 Rackspace Hosting Inc. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import logging
|
|
import traceback as tb
|
|
|
|
from celery import signals
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
@signals.task_failure.connect
|
|
def task_error_handler(signal=None, sender=None, task_id=None,
|
|
exception=None, args=None, kwargs=None,
|
|
traceback=None, einfo=None):
|
|
"""If a task errors out, log all error info"""
|
|
LOG.error('Task %s, id: %s, called with args: %s, and kwargs: %s'
|
|
'failed with exception: %s' % (sender.name, task_id,
|
|
args, kwargs, exception))
|
|
LOG.error('Trackeback: %s' % (tb.print_tb(traceback), ))
|
|
# TODO(jlucci): Auto-initiate rollback from failed task
|
|
|
|
|
|
@signals.task_success.connect
|
|
def task_success_handler(singal=None, sender=None, result=None):
|
|
"""Save task results to WF."""
|
|
pass
|