Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

agriconnect / opbeat   python

Repository URL to install this package:

Version: 3.5.3 

/ contrib / rq / __init__.py

def register_opbeat(client, worker):
    """Given a Opbeat client and an RQ worker, registers exception handlers
    with the worker so exceptions are logged to Opbeat.

    E.g.:

    from opbeat.contrib.django.models import client
    from opbeat.contrib.rq import register_opbeat
    
    worker = Worker(map(Queue, listen))
    register_opbeat(client, worker)
    worker.work()

    """
    def send_to_opbeat(job, *exc_info):
        client.capture_exception(
            exc_info=exc_info,
            extra={
                'job_id': job.id,
                'func': job.func_name,
                'args': job.args,
                'kwargs': job.kwargs,
                'description': job.description,
            }
        )

    worker.push_exc_handler(send_to_opbeat)