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


Python jsonapi.loads方法代码示例

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


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

示例1: server_status

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def server_status(self):
        """
            Get the current status of the server connected to this client

        :return: a dictionary contains the current status of the server connected to this client
        :rtype: dict[str, str]

        """
        try:
            self.receiver.setsockopt(zmq.RCVTIMEO, self.timeout)
            self._send(b'SHOW_CONFIG')
            return jsonapi.loads(self._recv().content[1])
        except zmq.error.Again as _e:
            t_e = TimeoutError(
                'no response from the server (with "timeout"=%d ms), '
                'is the server on-line? is network broken? are "port" and "port_out" correct?' % self.timeout)
            if _py2:
                raise t_e
            else:
                raise t_e from _e
        finally:
            self.receiver.setsockopt(zmq.RCVTIMEO, -1) 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:24,代码来源:__init__.py

示例2: recv_pyobj

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_pyobj(self, flags=0):
        """Receive a Python object as a message using pickle to serialize.

        Parameters
        ----------
        flags : int
            Any valid flags for :func:`Socket.recv`.

        Returns
        -------
        obj : Python object
            The Python object that arrives as a message.

        Raises
        ------
        ZMQError
            for any of the reasons :func:`~Socket.recv` might fail
        """
        msg = self.recv(flags)
        return self._deserialize(msg, pickle.loads) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:socket.py

示例3: recv_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_json(self, flags=0, **kwargs):
        """Receive a Python object as a message using json to serialize.

        Keyword arguments are passed on to json.loads
        
        Parameters
        ----------
        flags : int
            Any valid flags for :func:`Socket.recv`.

        Returns
        -------
        obj : Python object
            The Python object that arrives as a message.

        Raises
        ------
        ZMQError
            for any of the reasons :func:`~Socket.recv` might fail
        """
        from zmq.utils import jsonapi
        msg = self.recv(flags)
        return self._deserialize(msg, lambda buf: jsonapi.loads(buf, **kwargs)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:25,代码来源:socket.py

示例4: recv_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_json(self, flags=0):
        """receive a Python object as a message using json to serialize

        Parameters
        ----------
        flags : int
            Any valid recv flag.

        Returns
        -------
        obj : Python object
            The Python object that arrives as a message.
        """
        if jsonapi.jsonmod is None:
            raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
        else:
            msg = self.recv(flags)
            return jsonapi.loads(msg) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:socket.py

示例5: recv_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_json(self, flags=0, **kwargs):
        """Receive a Python object as a message using json to serialize.

        Keyword arguments are passed on to json.loads
        
        Parameters
        ----------
        flags : int
            Any valid flags for :func:`Socket.recv`.

        Returns
        -------
        obj : Python object
            The Python object that arrives as a message.

        Raises
        ------
        ZMQError
            for any of the reasons :func:`~Socket.recv` might fail
        """
        msg = self.recv(flags)
        return self._deserialize(msg, lambda buf: jsonapi.loads(buf, **kwargs)) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:24,代码来源:socket.py

示例6: _recv_ndarray

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def _recv_ndarray(self):
        request_id, response = self._recv()
        arr_info, arr_val = jsonapi.loads(response[1]), response[2]
        X = np.frombuffer(_buffer(arr_val), dtype=str(arr_info['dtype']))
        return Response(request_id, self.formatter(X.reshape(arr_info['shape']))) 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:7,代码来源:__init__.py

示例7: input_fn_builder

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def input_fn_builder(self, worker):
        def gen():
            while not self.exit_flag.is_set():
                client_id, msg = worker.recv_multipart()
                msg = jsonapi.loads(msg)
                self.logger.info('new job %s, size: %d' % (client_id, len(msg)))
                if BertClient.is_valid_input(msg):
                    tmp_f = list(convert_lst_to_features(msg, self.max_seq_len, self.tokenizer))
                    yield {
                        'client_id': client_id,
                        'input_ids': [f.input_ids for f in tmp_f],
                        'input_mask': [f.input_mask for f in tmp_f],
                        'input_type_ids': [f.input_type_ids for f in tmp_f]
                    }
                else:
                    self.logger.error('unsupported type of job %s! sending back None' % client_id)

        def input_fn():
            return (tf.data.Dataset.from_generator(
                gen,
                output_types={'input_ids': tf.int32,
                              'input_mask': tf.int32,
                              'input_type_ids': tf.int32,
                              'client_id': tf.string},
                output_shapes={
                    'client_id': (),
                    'input_ids': (None, self.max_seq_len),
                    'input_mask': (None, self.max_seq_len),
                    'input_type_ids': (None, self.max_seq_len)}))

        return input_fn 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:33,代码来源:server.py

示例8: recv_ndarray

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_ndarray(self):
        response = self.recv()
        arr_info, arr_val = jsonapi.loads(response[1]), response[2]
        X = np.frombuffer(_buffer(arr_val), dtype=arr_info['dtype'])
        return self.formatter(X.reshape(arr_info['shape'])) 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:7,代码来源:client.py

示例9: _recv_ndarray

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def _recv_ndarray(self, wait_for_req_id=None):
        request_id, response = self._recv(wait_for_req_id)
        arr_info, arr_val = jsonapi.loads(response[1]), response[2]
        X = np.frombuffer(_buffer(arr_val), dtype=str(arr_info['dtype']))
        return Response(request_id, self.formatter(X.reshape(arr_info['shape'])), arr_info.get('tokens', '')) 
开发者ID:hanxiao,项目名称:bert-as-service,代码行数:7,代码来源:__init__.py

示例10: server_config

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def server_config(self):
        """
            Get the current configuration of the server connected to this client

        :return: a dictionary contains the current configuration of the server connected to this client
        :rtype: dict[str, str]

        """
        req_id = self._send(b'SHOW_CONFIG')
        return jsonapi.loads(self._recv(req_id).content[1]) 
开发者ID:hanxiao,项目名称:bert-as-service,代码行数:12,代码来源:__init__.py

示例11: server_status

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def server_status(self):
        """
            Get the current status of the server connected to this client

        :return: a dictionary contains the current status of the server connected to this client
        :rtype: dict[str, str]

        """
        req_id = self._send(b'SHOW_STATUS')
        return jsonapi.loads(self._recv(req_id).content[1]) 
开发者ID:hanxiao,项目名称:bert-as-service,代码行数:12,代码来源:__init__.py

示例12: recv_pyobj

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def recv_pyobj(self, flags=0):
        """receive a Python object as a message using pickle to serialize

        Parameters
        ----------
        flags : int
            Any valid recv flag.

        Returns
        -------
        obj : Python object
            The Python object that arrives as a message.
        """
        s = self.recv(flags)
        return pickle.loads(s) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:socket.py

示例13: on_message

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def on_message(self, msg):
        msg = jsonapi.loads(msg)
        self.session.send(self.zmq_stream, msg) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:handlers.py

示例14: _recv_scores

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def _recv_scores(self, wait_for_req_id=None):
        request_id, response = self._recv(wait_for_req_id)
        scores = jsonapi.loads(response[1])
        return Response(request_id, scores) 
开发者ID:AIPHES,项目名称:emnlp19-moverscore,代码行数:6,代码来源:__init__.py

示例15: server_status

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import loads [as 别名]
def server_status(self):
        """
            Get the current status of the server connected to this client

        :return: a dictionary contains the current status of the server connected to this client
        :rtype: dict[str, str]

        """
        req_id = self._send(b'SHOW_CONFIG')
        return jsonapi.loads(self._recv(req_id).content[1]) 
开发者ID:AIPHES,项目名称:emnlp19-moverscore,代码行数:12,代码来源:__init__.py


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