/usr/lib/python2.7/dist-packages/celery/app/events.py is in python-celery 4.1.0-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | """Implementation for the app.events shortcuts."""
from __future__ import absolute_import, unicode_literals
from contextlib import contextmanager
from kombu.utils.objects import cached_property
class Events(object):
"""Implements app.events."""
receiver_cls = 'celery.events.receiver:EventReceiver'
dispatcher_cls = 'celery.events.dispatcher:EventDispatcher'
state_cls = 'celery.events.state:State'
def __init__(self, app=None):
self.app = app
@cached_property
def Receiver(self):
return self.app.subclass_with_self(
self.receiver_cls, reverse='events.Receiver')
@cached_property
def Dispatcher(self):
return self.app.subclass_with_self(
self.dispatcher_cls, reverse='events.Dispatcher')
@cached_property
def State(self):
return self.app.subclass_with_self(
self.state_cls, reverse='events.State')
@contextmanager
def default_dispatcher(self, hostname=None, enabled=True,
buffer_while_offline=False):
with self.app.amqp.producer_pool.acquire(block=True) as prod:
# pylint: disable=too-many-function-args
# This is a property pylint...
with self.Dispatcher(prod.connection, hostname, enabled,
prod.channel, buffer_while_offline) as d:
yield d
|