This file is indexed.

/usr/lib/python2.7/dist-packages/oslo_messaging/_drivers/zmq_driver/server/consumers/zmq_pull_consumer.py is in python-oslo.messaging 4.6.1-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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#    Copyright 2015 Mirantis, Inc.
#
#    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

from oslo_messaging._drivers import base
from oslo_messaging._drivers.zmq_driver.server.consumers\
    import zmq_consumer_base
from oslo_messaging._drivers.zmq_driver import zmq_address
from oslo_messaging._drivers.zmq_driver import zmq_async
from oslo_messaging._drivers.zmq_driver import zmq_names
from oslo_messaging._i18n import _LE, _LI

LOG = logging.getLogger(__name__)

zmq = zmq_async.import_zmq()


class PullIncomingMessage(base.RpcIncomingMessage):

    def __init__(self, context, message):
        super(PullIncomingMessage, self).__init__(context, message)

    def reply(self, reply=None, failure=None, log_failure=True):
        """Reply is not needed for non-call messages."""

    def acknowledge(self):
        """Acknowledgments are not supported by this type of consumer."""

    def requeue(self):
        """Requeueing is not supported."""


class PullConsumer(zmq_consumer_base.SingleSocketConsumer):

    def __init__(self, conf, poller, server):
        super(PullConsumer, self).__init__(conf, poller, server, zmq.PULL)
        self.matchmaker = server.matchmaker
        self.host = zmq_address.combine_address(self.conf.rpc_zmq_host,
                                                self.port)
        self.targets = zmq_consumer_base.TargetsManager(
            conf, self.matchmaker, self.host, zmq.PULL)
        LOG.info(_LI("[%s] Run PULL consumer"), self.host)

    def listen(self, target):
        LOG.info(_LI("Listen to target %s"), str(target))
        self.targets.listen(target)

    def cleanup(self):
        super(PullConsumer, self).cleanup()
        self.targets.cleanup()

    def receive_message(self, socket):
        try:
            request = socket.recv_pyobj()
            msg_type = request.msg_type
            assert msg_type is not None, 'Bad format: msg type expected'
            context = request.context
            message = request.message
            LOG.debug("[%(host)s] Received %(type)s, %(id)s, %(target)s",
                      {"host": self.host,
                       "type": request.msg_type,
                       "id": request.message_id,
                       "target": request.target})

            if msg_type in (zmq_names.CAST_TYPES + zmq_names.NOTIFY_TYPES):
                return PullIncomingMessage(context, message)
            else:
                LOG.error(_LE("Unknown message type: %s"), msg_type)

        except zmq.ZMQError as e:
            LOG.error(_LE("Receiving message failed: %s"), str(e))