本文整理汇总了Python中raven.contrib.celery.register_signal函数的典型用法代码示例。如果您正苦于以下问题:Python register_signal函数的具体用法?Python register_signal怎么用?Python register_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register_signal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: configure_error_handling
def configure_error_handling(sender, **kargs):
"""Rollbar and Sentry integration
Based on
https://www.mattlayman.com/blog/2017/django-celery-rollbar/
"""
if not bool(os.environ.get('CELERY_WORKER_RUNNING', False)):
return
from django.conf import settings
if HAS_ROLLBAR and hasattr(settings, 'ROLLBAR'):
rollbar.init(**settings.ROLLBAR)
def celery_base_data_hook(request, data):
data['framework'] = 'celery'
rollbar.BASE_DATA_HOOK = celery_base_data_hook
@task_failure.connect
def handle_task_failure(**kw):
rollbar.report_exc_info(extra_data=kw)
if HAS_RAVEN and hasattr(settings, 'RAVEN_CONFIG'):
client = Client(
settings.RAVEN_CONFIG['dsn'],
release=settings.RAVEN_CONFIG.get('release'),
environment=settings.RAVEN_CONFIG.get('environment'),
)
register_signal(client, ignore_expected=True)
register_logger_signal(client, loglevel=logging.ERROR)
开发者ID:dekoza,项目名称:weblate,代码行数:30,代码来源:celery.py
示例2: create_celery_app
def create_celery_app(app=None, config="worker"):
"""
adapted from http://flask.pocoo.org/docs/0.10/patterns/celery/
(added the wsgi_environ stuff)
"""
app = app or create_app(config=config)
celery.main = app.import_name
celery.conf["BROKER_URL"] = app.config["CELERY_BROKER_URL"]
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
if "wsgi_environ" in kwargs:
wsgi_environ = kwargs.pop("wsgi_environ")
else:
wsgi_environ = None
with app.app_context():
if wsgi_environ:
with app.request_context(wsgi_environ):
return TaskBase.__call__(self, *args, **kwargs)
else:
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
register_logger_signal(sentry.client)
register_signal(sentry.client)
return celery
开发者ID:stovar04,项目名称:openedx-webhooks,代码行数:28,代码来源:__init__.py
示例3: register_handlers
def register_handlers():
from django.core.signals import got_request_exception
# HACK: support Sentry's internal communication
if 'sentry' in django_settings.INSTALLED_APPS:
from django.db import transaction
@transaction.commit_on_success
def wrap_sentry(request, **kwargs):
if transaction.is_dirty():
transaction.rollback()
return sentry_exception_handler(request, **kwargs)
exception_handler = wrap_sentry
else:
exception_handler = sentry_exception_handler
# Connect to Django's internal signal handler
got_request_exception.connect(exception_handler)
# If Celery is installed, register a signal handler
if 'djcelery' in django_settings.INSTALLED_APPS:
from raven.contrib.celery import register_signal, register_logger_signal
try:
register_signal(client)
except Exception:
logger.exception('Failed installing error handling for Celery')
try:
register_logger_signal(client)
except Exception:
logger.exception('Failed installing logging handler for Celery')
开发者ID:raffstah,项目名称:raven,代码行数:33,代码来源:models.py
示例4: make_celery
def make_celery(app, celery):
""" From http://flask.pocoo.org/docs/0.10/patterns/celery/ """
# Register our custom serializer type before updating the configuration.
from kombu.serialization import register
from doorman.celery_serializer import djson_dumps, djson_loads
register(
'djson', djson_dumps, djson_loads,
content_type='application/x-djson',
content_encoding='utf-8'
)
# Actually update the config
celery.config_from_object(app.config)
# Register Sentry client
if 'SENTRY_DSN' in app.config and app.config['SENTRY_DSN']:
client = Client(app.config['SENTRY_DSN'])
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
return celery
开发者ID:mwielgoszewski,项目名称:doorman,代码行数:35,代码来源:extensions.py
示例5: create_app
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
celery.conf.update(app.config)
db.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
if not app.config['DEBUG']:
# https://docs.getsentry.com/hosted/clients/python/integrations/flask/
sentry.init_app(app, dsn=app.config['SENTRY_DSN'])
# https://docs.getsentry.com/hosted/clients/python/integrations/celery/
client = Client(app.config['SENTRY_DSN'])
register_logger_signal(client)
register_signal(client)
from .admin import admin as admin_blueprint
app.register_blueprint(admin_blueprint, url_prefix='/admin')
from .api_v1 import api_module as api_blueprint
app.register_blueprint(api_blueprint, url_prefix='/api/v1')
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
from .public import public as public_blueprint
app.register_blueprint(public_blueprint)
return app
开发者ID:clausmith,项目名称:flash,代码行数:32,代码来源:__init__.py
示例6: on_configure
def on_configure(self):
if 'raven.contrib.django.raven_compat' in settings.INSTALLED_APPS:
client = raven.Client(**settings.RAVEN_CONFIG)
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:sergeii,项目名称:swat4stats.com,代码行数:7,代码来源:celery.py
示例7: init_celery
def init_celery():
"""
Initialize Celery, and make our app instance available as `celery_app`
for use by the `celery` command.
"""
from django.conf import settings
from raven import Client
from raven.contrib.celery import register_signal, register_logger_signal
from amo import celery
# I think `manage.py celery` relies on this global? We typically don't run
# celery like that anymore though.
global celery_app
celery_app = celery.app
# Hook up Sentry in celery.
client = Client(settings.SENTRY_DSN)
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
# After upgrading raven we can specify loglevel=logging.INFO to override
# the default (which is ERROR).
register_logger_signal(client)
开发者ID:peterkinalex,项目名称:olympia,代码行数:27,代码来源:olympia.py
示例8: __init__
def __init__(self, app):
if app.config.get('SENTRY_DSN'):
app.config.setdefault('SENTRY_NAME', app.config.get('SERVER_NAME'))
self.sentry = Sentry(app, register_signal=False, wrap_wsgi=False, logging=True, level=logging.WARNING)
register_logger_signal(self.sentry.client)
register_signal(self.sentry.client)
else:
self.sentry = None
开发者ID:nistormihai,项目名称:superdesk-core,代码行数:8,代码来源:sentry.py
示例9: on_configure
def on_configure(self):
client = raven.Client(settings.RAVEN_URL)
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:rapidpro,项目名称:data_api,代码行数:8,代码来源:celery.py
示例10: on_configure
def on_configure(self):
client = RavenClient(SETTINGS.get('sentry_dsn'))
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:DanHanson82,项目名称:quickbooks-desktop-python,代码行数:8,代码来源:celery_app.py
示例11: on_configure
def on_configure(self):
if settings.SENTRY_ENABLED:
import raven
from raven.contrib.celery import register_signal, register_logger_signal
client = raven.Client(settings.RAVEN_CONFIG["dsn"])
register_logger_signal(client)
register_signal(client)
开发者ID:ricebeans,项目名称:nodeshot,代码行数:8,代码来源:celery.py
示例12: init_app
def init_app(self, app):
self.app = app
self.config_from_object(app.config)
if 'SENTRY_DSN' in app.config and app.config['SENTRY_DSN'] is not None:
self.sentry = raven.Client(app.config['SENTRY_DSN'])
register_logger_signal(self.sentry)
register_signal(self.sentry)
开发者ID:parryjacob,项目名称:flask-boilerplate,代码行数:8,代码来源:__init__.py
示例13: on_configure
def on_configure(self):
if hasattr(settings, 'RAVEN_CONFIG') and settings.RAVEN_CONFIG['dsn']:
import raven
from raven.contrib.celery import (register_signal,
register_logger_signal)
client = raven.Client(settings.RAVEN_CONFIG['dsn'])
register_logger_signal(client)
register_signal(client)
开发者ID:COLABORATI,项目名称:nodeshot,代码行数:8,代码来源:celery.py
示例14: on_configure
def on_configure(self):
client = raven.Client(SENTRY_LINK)
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:triump0870,项目名称:RemindMeLater,代码行数:8,代码来源:celery_app.py
示例15: on_configure
def on_configure(self):
client = raven.Client(os.getenv('SENTRY_DSN'), environment=os.getenv('SENTRY_ENVIRONMENT'))
# Always ensure you import register_logger_signal, register_signal and not their parent modules
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:CuriousLearner,项目名称:django-init,代码行数:9,代码来源:celery.py
示例16: on_configure
def on_configure(self): # pylint: disable=method-hidden
if not client:
return
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:DavidCain,项目名称:mitoc-trips,代码行数:9,代码来源:celery_config.py
示例17: on_configure
def on_configure(self):
from raven.contrib.django.models import client
from raven.contrib.celery import register_signal, register_logger_signal
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:280185386,项目名称:sentry,代码行数:9,代码来源:celery.py
示例18: on_configure
def on_configure(self):
if not getattr(settings, 'CELERY_RAVEN_DSN'):
# for no send raven reports from dev server
return
client = raven.Client(settings.CELERY_RAVEN_DSN)
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:Samael500,项目名称:falstart-example,代码行数:9,代码来源:celery.py
示例19: ready
def ready(self):
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
if hasattr(settings, 'RAVEN_CONFIG'):
# Celery signal registration
client = Client(dsn=settings.RAVEN_CONFIG['dsn'])
register_signal(client)
开发者ID:Eraldo,项目名称:sandbox,代码行数:10,代码来源:celery.py
示例20: on_configure
def on_configure(self):
if settings.PDB_ENABLE_SENTRY: # ignore for coverage
client = raven.Client(settings.PDB_SENTRY_DSN)
client.release = raven.fetch_git_sha(os.path.dirname(os.pardir))
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
开发者ID:hoelsner,项目名称:product-database,代码行数:10,代码来源:celery.py
注:本文中的raven.contrib.celery.register_signal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论