This file is indexed.

/usr/share/pyshared/txzmq/router_dealer.py is in python-txzmq 0.6.2-1.

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
"""
ZeroMQ ROUTER and DEALER connection types.
"""
from zmq.core import constants

from txzmq.connection import ZmqConnection


# TODO: ideally, all connection classes would inherit from this in the future
# so that we'd have a consistent wrapper API over all underlying socket types.
class ZmqBase(ZmqConnection):
    """
    Base class for all ZMQ connection classes with a uniform interface.

    Subclasses should override sendMsg and sendMultipart with their own
    connection-type specific implementations, which can have a different
    argument signature. Thus, ZmqBase does not attempt to hide away the
    differences between different connection classes--this is simply
    impossible--It simply attempts to provide a more consistent way of
    interacting with them.

    By default, these methods simply delegate to the unerlying low-level
    ZmqConnection.send, which handles both single and multi-part messages.

    Subclasses can/should add their own semantic aliases for sendMsg and
    sendMultipart, such as publish and publishMultipart for a PUB socket.
    """
    def sendMsg(self, message):
        """
        Provides a higher level wrapper over ZmqConnection.send for sending
        single-part messages.

        @param message: message data
        @type message: C{str}
        """
        self.sendMultipart([message])

    def sendMultipart(self, parts):
        """
        Provides a higher level wrapper over ZmqConnection.send for sending
        multipart messages.

        @param parts: message data
        """
        self.send(parts)

    def messageReceived(self, message):
        """
        Called on incoming message from ZeroMQ.

        Override this to handle generic messages received and pass them to
        gotMessage with a socket-type specific signature.

        @param message: message data
        """
        self.gotMessage(*message)

    def gotMessage(self, *args, **kwargs):
        raise NotImplementedError


class ZmqDealerConnection(ZmqBase):
    """
    A DEALER connection.
    """
    socketType = constants.DEALER


class ZmqRouterConnection(ZmqBase):
    """
    A ROUTER connection.
    """
    socketType = constants.ROUTER

    def sendMsg(self, recipientId, message):
        self.send([recipientId, message])

    def sendMultipart(self, recipientId, parts):
        self.send([recipientId] + parts)

    def messageReceived(self, message):
        sender_id = message.pop(0)
        self.gotMessage(sender_id, *message)