當前位置: 首頁>>代碼示例>>Python>>正文


Python zmq.utils方法代碼示例

本文整理匯總了Python中zmq.utils方法的典型用法代碼示例。如果您正苦於以下問題:Python zmq.utils方法的具體用法?Python zmq.utils怎麽用?Python zmq.utils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zmq的用法示例。


在下文中一共展示了zmq.utils方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_json

# 需要導入模塊: import zmq [as 別名]
# 或者: from zmq import utils [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: recv_json

# 需要導入模塊: import zmq [as 別名]
# 或者: from zmq import utils [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

示例3: shadow

# 需要導入模塊: import zmq [as 別名]
# 或者: from zmq import utils [as 別名]
def shadow(cls, address):
        """Shadow an existing libzmq socket
        
        address is the integer address of the libzmq socket
        or an FFI pointer to it.
        
        .. versionadded:: 14.1
        """
        from zmq.utils.interop import cast_int_addr
        address = cast_int_addr(address)
        return cls(shadow=address)
    
    #-------------------------------------------------------------------------
    # Deprecated aliases
    #------------------------------------------------------------------------- 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:17,代碼來源:socket.py

示例4: test_utils

# 需要導入模塊: import zmq [as 別名]
# 或者: from zmq import utils [as 別名]
def test_utils(self):
        """test util imports"""
        import zmq.utils
        from zmq.utils import strtypes
        from zmq.utils import jsonapi 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:7,代碼來源:test_imports.py

示例5: patch_pyzmq

# 需要導入模塊: import zmq [as 別名]
# 或者: from zmq import utils [as 別名]
def patch_pyzmq():
    """backport a few patches from newer pyzmq
    
    These can be removed as we bump our minimum pyzmq version
    """
    
    import zmq
    
    # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things.
    # jsonlib support is removed from pyzmq >= 2.2.0

    from zmq.utils import jsonapi
    if jsonapi.jsonmod.__name__ == 'jsonlib':
        import json
        jsonapi.jsonmod = json 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:17,代碼來源:zmqrelated.py


注:本文中的zmq.utils方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。