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


Python jsonapi.dumps方法代码示例

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


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

示例1: send_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_json(self, obj, flags=0, **kwargs):
        """Send a Python object as a message using json to serialize.
        
        Keyword arguments are passed on to json.dumps
        
        Parameters
        ----------
        obj : Python object
            The Python object to send
        flags : int
            Any valid flags for :func:`Socket.send`
        """
        from zmq.utils import jsonapi
        send_kwargs = {}
        for key in ('routing_id', 'group'):
            if key in kwargs:
                send_kwargs[key] = kwargs.pop(key)
        msg = jsonapi.dumps(obj, **kwargs)
        return self.send(msg, flags=flags, **send_kwargs) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:21,代码来源:socket.py

示例2: send_pyobj

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_pyobj(self, obj, flags=0, protocol=-1):
        """send a Python object as a message using pickle to serialize

        Parameters
        ----------
        obj : Python object
            The Python object to send.
        flags : int
            Any valid send flag.
        protocol : int
            The pickle protocol number to use. Default of -1 will select
            the highest supported number. Use 0 for multiple platform
            support.
        """
        msg = pickle.dumps(obj, protocol)
        return self.send(msg, flags) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:socket.py

示例3: _reserialize_reply

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def _reserialize_reply(self, msg_list):
        """Reserialize a reply message using JSON.

        This takes the msg list from the ZMQ socket, unserializes it using
        self.session and then serializes the result using JSON. This method
        should be used by self._on_zmq_reply to build messages that can
        be sent back to the browser.
        """
        idents, msg_list = self.session.feed_identities(msg_list)
        msg = self.session.unserialize(msg_list)
        try:
            msg['header'].pop('date')
        except KeyError:
            pass
        try:
            msg['parent_header'].pop('date')
        except KeyError:
            pass
        msg.pop('buffers')
        return jsonapi.dumps(msg, default=date_default) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:zmqhandlers.py

示例4: post

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def post(self, profile, action):
        cm = self.cluster_manager
        if action == 'start':
            n = self.get_argument('n', default=None)
            if not n:
                data = cm.start_cluster(profile)
            else:
                data = cm.start_cluster(profile, int(n))
        if action == 'stop':
            data = cm.stop_cluster(profile)
        self.finish(jsonapi.dumps(data))


#-----------------------------------------------------------------------------
# URL to handler mappings
#----------------------------------------------------------------------------- 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:handlers.py

示例5: send_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_json(self, obj, flags=0, **kwargs):
        """Send a Python object as a message using json to serialize.
        
        Keyword arguments are passed on to json.dumps
        
        Parameters
        ----------
        obj : Python object
            The Python object to send
        flags : int
            Any valid flags for :func:`Socket.send`
        """
        send_kwargs = {}
        for key in ('routing_id', 'group'):
            if key in kwargs:
                send_kwargs[key] = kwargs.pop(key)
        msg = jsonapi.dumps(obj, **kwargs)
        return self.send(msg, flags=flags, **send_kwargs) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:20,代码来源:socket.py

示例6: eval

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def eval(self, pairs):
        """ Encode a list of strings to a list of vectors

        `texts` should be a list of strings, each of which represents a sentence.
        If `is_tokenized` is set to True, then `texts` should be list[list[str]],
        outer list represents sentence and inner list represent tokens in the sentence.
        Note that if `blocking` is set to False, then you need to fetch the result manually afterwards.

        .. highlight:: python
        .. code-block:: python

            with EvalClient() as bc:
                # evaluate pair of summary and references untokenized sentences
                bc.eval([['summary'], [ref]])
            :rtype: dictionary {}

        """
        
        req_id = self._send(jsonapi.dumps(pairs), len(pairs))
        
        r = self._recv_scores(req_id)
        
        return r.scores 
开发者ID:AIPHES,项目名称:emnlp19-moverscore,代码行数:25,代码来源:__init__.py

示例7: send_ndarray

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_ndarray(src, dest, X, flags=0, copy=True, track=False):
    """send a numpy array with metadata"""
    md = dict(dtype=str(X.dtype), shape=X.shape)
    return src.send_multipart([dest, jsonapi.dumps(md), X], flags, copy=copy, track=track) 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:6,代码来源:server.py

示例8: encode

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def encode(self, texts, blocking=True):
        if self.is_valid_input(texts):
            texts = _unicode(texts)
            self.send(jsonapi.dumps(texts))
            return self.recv_ndarray() if blocking else None
        else:
            raise AttributeError('"texts" must be "List[str]" and non-empty!') 
开发者ID:a414351664,项目名称:Bert-TextClassification,代码行数:9,代码来源:client.py

示例9: configure_plain

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def configure_plain(self, domain='*', passwords=None):
        self.pipe.send_multipart([b'PLAIN', b(domain, self.encoding), jsonapi.dumps(passwords or {})]) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:4,代码来源:thread.py

示例10: send_pyobj

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_pyobj(self, obj, flags=0, protocol=DEFAULT_PROTOCOL, **kwargs):
        """Send a Python object as a message using pickle to serialize.

        Parameters
        ----------
        obj : Python object
            The Python object to send.
        flags : int
            Any valid flags for :func:`Socket.send`.
        protocol : int
            The pickle protocol number to use. The default is pickle.DEFAULT_PROTOCOL
            where defined, and pickle.HIGHEST_PROTOCOL elsewhere.
        """
        msg = pickle.dumps(obj, protocol)
        return self.send(msg, flags=flags, **kwargs) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:17,代码来源:socket.py

示例11: send_json

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_json(self, obj, flags=0, callback=None, **kwargs):
        """Send json-serialized version of an object.
        See zmq.socket.send_json for details.
        """
        if jsonapi is None:
            raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
        else:
            msg = jsonapi.dumps(obj)
            return self.send(msg, flags=flags, callback=callback, **kwargs) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:zmqstream.py

示例12: send_pyobj

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_pyobj(self, obj, flags=0, protocol=-1, callback=None, **kwargs):
        """Send a Python object as a message using pickle to serialize.

        See zmq.socket.send_json for details.
        """
        msg = pickle.dumps(obj, protocol)
        return self.send(msg, flags, callback=callback, **kwargs) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:zmqstream.py

示例13: result

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def result(self):
        if self.max_seq_len_unset and not self.fixed_embed_length:
            x = np.ascontiguousarray(self.final_ndarray[:, 0:self.max_effective_len])
        else:
            x = self.final_ndarray
        x_info = {'dtype': str(x.dtype),
                  'shape': x.shape,
                  'tokens': list(chain.from_iterable(self.tokens)) if self.with_tokens else ''}

        x_info = jsonapi.dumps(x_info)
        return x, x_info 
开发者ID:hanxiao,项目名称:bert-as-service,代码行数:13,代码来源:__init__.py

示例14: send_ndarray

# 需要导入模块: from zmq.utils import jsonapi [as 别名]
# 或者: from zmq.utils.jsonapi import dumps [as 别名]
def send_ndarray(src, dest, X, req_id=b'', flags=0, copy=True, track=False):
    """send a numpy array with metadata"""
    md = dict(dtype=str(X.dtype), shape=X.shape)
    return src.send_multipart([dest, jsonapi.dumps(md), X, req_id], flags, copy=copy, track=track) 
开发者ID:hanxiao,项目名称:bert-as-service,代码行数:6,代码来源:helper.py

示例15: send_json

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

        Parameters
        ----------
        obj : Python object
            The Python object to send.
        flags : int
            Any valid send flag.
        """
        if jsonapi.jsonmod is None:
            raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
        else:
            msg = jsonapi.dumps(obj)
            return self.send(msg, flags) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:socket.py


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