Пример #1
0
        def run(self):
            print('Start data provider {}-{}'.format(self.pipename, self.identity))
            setproctitle('data provider {}-{}'.format(self.pipename, self.identity))
            ctx = zmq.Context()
            socket = ctx.socket(zmq.DEALER)
            socket.setsockopt(zmq.IDENTITY, self.identity)
            socket.set_hwm(self.hwm)
            socket.connect(self.pipename)

            while True:
                dp = loads(socket.recv(copy=False).bytes)
                dp = self.map_func(dp)
                socket.send(dumps(dp), copy=False)
Пример #2
0
    def _test_round_trip(self, obj):

        dumped = dumps(obj, self.FMT)

        # dumps / loads
        self.assertEqual(obj, loads(dumped, self.FMT))

        buf = io.BytesIO()
        dump(obj, buf, self.FMT)

        # dump / dumps
        self.assertEqual(dumped, buf.getvalue())

        buf.seek(0)
        # dump / load
        self.assertEqual(obj, load(buf, self.FMT))
Пример #3
0
    def _test_round_trip(self, obj):

        dumped = dumps(obj, self.FMT)

        # dumps / loads
        self.assertEqual(obj, loads(dumped, self.FMT))

        buf = io.BytesIO()
        dump(obj, buf, self.FMT)

        # dump / dumps
        self.assertEqual(dumped, buf.getvalue())

        buf.seek(0)
        # dump / load
        self.assertEqual(obj, load(buf, self.FMT))
Пример #4
0
 def _send(self, dp):
     # round-robin assignment
     worker = next(self._iter_worker)
     msg = [worker, dumps(dp)]
     self.socket.send_multipart(msg, copy=False)
Пример #5
0
    def test_response_bytes(self):

        obj = "here I am"

        self.assertIsInstance(dumps(obj, self.FMT), bytes)
Пример #6
0
    def test_response_bytes(self):

        obj = 'here I am'

        self.assertIsInstance(dumps(obj, self.FMT), bytes)