agent.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:osbrain 作者: opensistemas-hub 项目源码 文件源码
def _bind_socket(self, socket, addr=None, transport=None):
        """
        Bind a socket using the corresponding transport and address.

        Parameters
        ----------
        socket : zmq.Socket
            Socket to bind.
        addr : str, default is None
            The address to bind to.
        transport : str, AgentAddressTransport, default is None
            Transport protocol.

        Returns
        -------
        addr : str
            The address where the socket binded to.
        """
        if transport == 'tcp':
            host, port = address_to_host_port(addr)
            if not port:
                uri = 'tcp://%s' % self.host
                port = socket.bind_to_random_port(uri)
                addr = self.host + ':' + str(port)
            else:
                socket.bind('tcp://%s' % (addr))
        else:
            if not addr:
                addr = str(unique_identifier())
            if transport == 'ipc':
                addr = config['IPC_DIR'] / addr
            socket.bind('%s://%s' % (transport, addr))
        return addr
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号