当前位置: 首页>>代码示例>>Python>>正文


Python TSocket.setHandle方法代码示例

本文整理汇总了Python中thrift.transport.TSocket.TSocket.setHandle方法的典型用法代码示例。如果您正苦于以下问题:Python TSocket.setHandle方法的具体用法?Python TSocket.setHandle怎么用?Python TSocket.setHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thrift.transport.TSocket.TSocket的用法示例。


在下文中一共展示了TSocket.setHandle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: serveClient

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
    def serveClient(self, socket, address):
        """Process input/output from a client for as long as possible"""
        client = TSocket()
        client.setHandle(socket)
        self.peerName = client.getPeerName()
        thread_info = current_thread()

        itrans = self.inputTransportFactory.getTransport(client)
        otrans = self.outputTransportFactory.getTransport(client)
        iprot = self.inputProtocolFactory.getProtocol(itrans)
        if isinstance(self.inputProtocolFactory, THeaderProtocolFactory):
            oprot = iprot
        else:
            oprot = self.outputProtocolFactory.getProtocol(otrans)

        try:
            while True:
                if isinstance(getattr(self.processor._handler, 'peerName', None), dict):
                    self.processor._handler.peerName[thread_info] = client.getPeerName()
                else:
                    self.processor._handler.peerName = {thread_info: client.getPeerName()}
                self.processor.process(iprot, oprot)
        except TTransportException as tx:
            pass
        except Exception as x:
            self.logger.error('[%s]', x, extra={'clientip': client.getPeerName()})

        itrans.close()
        otrans.close()
开发者ID:SmartgreenSA,项目名称:fbthrift,代码行数:31,代码来源:TGeventServer.py

示例2: TLateInitSSLSocket

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
class TLateInitSSLSocket(TTransportBase):
    def __init__(self, handle):
        self.handle = handle
        self.socket = None

    def getSocket(self):
        if self.socket is None:
            self.handle.do_handshake()
            self.socket = TSocket()
            self.socket.setHandle(self.handle)
        return self.socket

    def isOpen(self):
        return self.getSocket().isOpen()

    def setTimeout(self, ms):
        return self.getSocket().setTimeout(ms)

    def read(self, sz):
        return self.getSocket().read(sz)

    def write(self, sz):
        return self.getSocket().write(sz)

    def flush(self):
        return self.getSocket().flush()

    def close(self):
        if self.socket is None:
            self.handle.close()
        else:
            return self.getSocket().close()
开发者ID:zielmicha,项目名称:satori,代码行数:34,代码来源:processes.py

示例3: handle_stream

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
 def handle_stream(self, sock, address):
     tsock = TSocket()
     tsock.setHandle(sock)
     itrans = self.itrans.getTransport(tsock) 
     otrans = self.otrans.getTransport(tsock)
     iprot = self.iprot.getProtocol(itrans)
     oprot = self.oprot.getProtocol(otrans)
     try:
         while True:
             self.processor.process(iprot, oprot)
     except TTransportException, ex:
         pass
开发者ID:zs-2014,项目名称:util,代码行数:14,代码来源:geventserver.py

示例4: handle

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
    def handle(self, client_socket, _):
        client = TSocket()
        client.setHandle(client_socket)

        trans = self.transport_factory.getTransport(client)
        prot = self.protocol_factory.getProtocol(trans)

        server_context = TRpcConnectionContext(client, prot, prot)

        try:
            while self.started:
                self.processor.process(prot, prot, server_context)
        except TTransportException:
            pass
        finally:
            trans.close()
开发者ID:ckwang8128,项目名称:baseplate,代码行数:18,代码来源:thrift.py

示例5: serveClient

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
    def serveClient(self, socket, address):
        """Process input/output from a client for as long as possible"""
        client = TSocket()
        client.setHandle(socket)
        itrans = self.inputTransportFactory.getTransport(client)
        otrans = self.outputTransportFactory.getTransport(client)
        iprot = self.inputProtocolFactory.getProtocol(itrans)
        if isinstance(self.inputProtocolFactory, THeaderProtocolFactory):
            oprot = iprot
        else:
            oprot = self.outputProtocolFactory.getProtocol(otrans)

        try:
            while True:
                self.processor.process(iprot, oprot)
        except TTransportException as tx:
            pass
        except Exception as x:
            logging.exception(x)

        itrans.close()
        otrans.close()
开发者ID:ConfusedReality,项目名称:pkg_serialization_fbthrift,代码行数:24,代码来源:TGeventServer.py

示例6: accept

# 需要导入模块: from thrift.transport.TSocket import TSocket [as 别名]
# 或者: from thrift.transport.TSocket.TSocket import setHandle [as 别名]
    def accept(self):
        while True:
            plain_client, addr = self.handle.accept()
            #print self.allowed_ips, addr[0]
            if self.allowed_ips and addr[0] not in self.allowed_ips:
                logging.warn ("client %s is not allowed to connect" % (addr[0]))
                plain_client.close()
                continue

            try:
                client = ssl.wrap_socket(plain_client, certfile=self.certfile,
                              server_side=True, ssl_version=self.SSL_VERSION)
            except (ssl.SSLError), e:
              # failed handshake/ssl wrap, close socket to client
                plain_client.close()
                logging.exception (e)
                continue

            result = TSocket()
            result.setHandle(client)
            
            return result
开发者ID:wangxiaomo,项目名称:vps,代码行数:24,代码来源:server.py


注:本文中的thrift.transport.TSocket.TSocket.setHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。