Exemplo n.º 1
0
        def call_async(stream):
            # print 'connect cb'
            msg = {
                'msgid': next(generator),
                'method': method_name,
                'params': params,
                'mode': self.mode
            }
            # print 'send msgid:', msg['msgid'], os.getpid()

            def recv_cb(data):
                # print 'send cb'
                stream.close()
                cb(data)

            netutils.send(stream, msg, callback=lambda: netutils.recv(stream, recv_cb))
Exemplo n.º 2
0
 def _request(self, method, params=[], mode=config.CALL_MODE):
     if self.stream.closed():
         # when connection has been disconnected, connect server
         yield self._connect()
     msg = {
         'id': next(self.gen_id),
         'method': method,
         'params': params,
         'mode': mode,
     }
     yield netutils.send(msg, self.stream)
     data = yield netutils.recv(self.stream)
     raise gen.Return(data)