當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。