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


Python zmq.zmq_version_info方法代码示例

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


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

示例1: get_hwm

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def get_hwm(self):
        """Get the High Water Mark.
        
        On libzmq ≥ 3, this gets SNDHWM if available, otherwise RCVHWM
        """
        major = zmq.zmq_version_info()[0]
        if major >= 3:
            # return sndhwm, fallback on rcvhwm
            try:
                return self.getsockopt(zmq.SNDHWM)
            except zmq.ZMQError:
                pass
            
            return self.getsockopt(zmq.RCVHWM)
        else:
            return self.getsockopt(zmq.HWM) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:socket.py

示例2: get_hwm

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def get_hwm(self):
        """get the High Water Mark
        
        On libzmq ≥ 3, this gets SNDHWM if available, otherwise RCVHWM
        """
        major = zmq.zmq_version_info()[0]
        if major >= 3:
            # return sndhwm, fallback on rcvhwm
            try:
                return self.getsockopt(zmq.SNDHWM)
            except zmq.ZMQError as e:
                pass
            
            return self.getsockopt(zmq.RCVHWM)
        else:
            return self.getsockopt(zmq.HWM) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:socket.py

示例3: set_hwm

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def set_hwm(self, value):
        """set the High Water Mark
        
        On libzmq ≥ 3, this sets both SNDHWM and RCVHWM
        """
        major = zmq.zmq_version_info()[0]
        if major >= 3:
            raised = None
            try:
                self.sndhwm = value
            except Exception as e:
                raised = e
            try:
                self.rcvhwm = value
            except Exception:
                raised = e
            
            if raised:
                raise raised
        else:
            return self.setsockopt(zmq.HWM, value) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:socket.py

示例4: monitor

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def monitor(self, addr, events=-1):
        """s.monitor(addr, flags)

        Start publishing socket events on inproc.
        See libzmq docs for zmq_monitor for details.
        
        Note: requires libzmq >= 3.2
        
        Parameters
        ----------
        addr : str
            The inproc url used for monitoring.
        events : int [default: zmq.EVENT_ALL]
            The zmq event bitmask for which events will be sent to the monitor.
        """
        if zmq.zmq_version_info() < (3,2):
            raise NotImplementedError("monitor requires libzmq >= 3.2, have %s" % zmq.zmq_version())
        if events < 0:
            events = zmq.EVENT_ALL
        rc = C.zmq_socket_monitor(self._zmq_socket, addr, events) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:socket.py

示例5: test_curve_public

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_curve_public(self):
        """test curve_public"""
        try:
            public, secret = zmq.curve_keypair()
        except zmq.ZMQError:
            raise SkipTest("CURVE unsupported")
        if zmq.zmq_version_info() < (4,2):
            raise SkipTest("curve_public is new in libzmq 4.2")

        derived_public = zmq.curve_public(secret)

        self.assertEqual(type(derived_public), bytes)
        self.assertEqual(len(derived_public), 40)

        # verify that it is indeed Z85
        bpublic = z85.decode(derived_public)
        self.assertEqual(type(bpublic), bytes)
        self.assertEqual(len(bpublic), 32)

        # verify that it is equal to the known public key
        self.assertEqual(derived_public, public) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:23,代码来源:test_security.py

示例6: __init__

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def __init__(self, opts):
        '''
        Create a salt broker instance
        '''
        self.opts = opts
        # Warn if ZMQ < 3.2
        try:
            zmq_version_info = zmq.zmq_version_info()
        except AttributeError:
            # PyZMQ <= 2.1.9 does not have zmq_version_info, fall back to
            # using zmq.zmq_version() and build a version info tuple.
            zmq_version_info = tuple(
                [int(x) for x in zmq.zmq_version().split('.')]
            )
        if zmq_version_info < (3, 2):
            log.warning(
                'You have a version of ZMQ less than ZMQ 3.2! There are '
                'known connection keep-alive issues with ZMQ < 3.2 which '
                'may result in loss of contact with minions. Please '
                'upgrade your ZMQ!'
            ) 
开发者ID:pengyao,项目名称:salt-broker,代码行数:23,代码来源:broker.py

示例7: _check_version

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def _check_version(min_version_info, msg='Feature'):
    """Check for libzmq
    
    raises ZMQVersionError if current zmq version is not at least min_version
    
    min_version_info is a tuple of integers, and will be compared against zmq.zmq_version_info().
    """
    global _zmq_version_info
    if _zmq_version_info is None:
        from zmq import zmq_version_info
        _zmq_version_info = zmq_version_info()
    if _zmq_version_info < min_version_info:
        min_version = '.'.join(str(v) for v in min_version_info)
        raise ZMQVersionError(min_version, msg) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:error.py

示例8: set_hwm

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def set_hwm(self, value):
        """Set the High Water Mark.
        
        On libzmq ≥ 3, this sets both SNDHWM and RCVHWM


        .. warning::

            New values only take effect for subsequent socket
            bind/connects.
        """
        major = zmq.zmq_version_info()[0]
        if major >= 3:
            raised = None
            try:
                self.sndhwm = value
            except Exception as e:
                raised = e
            try:
                self.rcvhwm = value
            except Exception as e:
                raised = e
            
            if raised:
                raise raised
        else:
            return self.setsockopt(zmq.HWM, value) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:29,代码来源:socket.py

示例9: get_monitor_socket

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def get_monitor_socket(self, events=None, addr=None):
        """Return a connected PAIR socket ready to receive the event notifications.
        
        .. versionadded:: libzmq-4.0
        .. versionadded:: 14.0
        
        Parameters
        ----------
        events : int [default: ZMQ_EVENTS_ALL]
            The bitmask defining which events are wanted.
        addr :  string [default: None]
            The optional endpoint for the monitoring sockets.

        Returns
        -------
        socket :  (PAIR)
            The socket is already connected and ready to receive messages.
        """
        # safe-guard, method only available on libzmq >= 4
        if zmq.zmq_version_info() < (4,):
            raise NotImplementedError("get_monitor_socket requires libzmq >= 4, have %s" % zmq.zmq_version())

        # if already monitoring, return existing socket
        if self._monitor_socket:
            if self._monitor_socket.closed:
                self._monitor_socket = None
            else:
                return self._monitor_socket

        if addr is None:
            # create endpoint name from internal fd
            addr = "inproc://monitor.s-%d" % self.FD
        if events is None:
            # use all events
            events = zmq.EVENT_ALL
        # attach monitoring socket
        self.monitor(addr, events)
        # create new PAIR socket and connect it
        self._monitor_socket = self.context.socket(zmq.PAIR)
        self._monitor_socket.connect(addr)
        return self._monitor_socket 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:43,代码来源:socket.py

示例10: test_zmq_version_info

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_zmq_version_info(self):
        info = zmq.zmq_version_info()
        self.assertTrue(isinstance(info, tuple))
        for n in info[:3]:
            self.assertTrue(isinstance(n, int)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:test_version.py

示例11: _select_recv

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def _select_recv(self, multipart, socket, **kwargs):
        """call recv[_multipart] in a way that raises if there is nothing to receive"""
        if zmq.zmq_version_info() >= (3,1,0):
            # zmq 3.1 has a bug, where poll can return false positives,
            # so we wait a little bit just in case
            # See LIBZMQ-280 on JIRA
            time.sleep(0.1)
        
        r,w,x = zmq.select([socket], [], [], timeout=kwargs.pop('timeout', 5))
        assert len(r) > 0, "Should have received a message"
        kwargs['flags'] = zmq.DONTWAIT | kwargs.get('flags', 0)
        
        recv = socket.recv_multipart if multipart else socket.recv
        return recv(**kwargs) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:__init__.py

示例12: test_dir

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_dir(self):
        ctx = self.Context()
        self.assertTrue('socket' in dir(ctx))
        if zmq.zmq_version_info() > (3,):
            self.assertTrue('IO_THREADS' in dir(ctx))
        ctx.term() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:test_context.py

示例13: test_ctx_opts

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_ctx_opts(self):
        if zmq.zmq_version_info() < (3,):
            raise SkipTest("context options require libzmq 3")
        ctx = self.Context()
        ctx.set(zmq.MAX_SOCKETS, 2)
        self.assertEqual(ctx.get(zmq.MAX_SOCKETS), 2)
        ctx.max_sockets = 100
        self.assertEqual(ctx.max_sockets, 100)
        self.assertEqual(ctx.get(zmq.MAX_SOCKETS), 100) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:test_context.py

示例14: test_draft

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_draft(self):
        zmq_version = zmq.zmq_version_info()
        for version, new_names in constant_names.draft_in.items():
            should_have = zmq_version >= version
            for name in new_names:
                try:
                    value = getattr(zmq, name)
                except AttributeError:
                    if should_have:
                        self.fail("AttributeError: zmq.%s" % name)
                else:
                    if not should_have:
                        self.fail("Shouldn't have: zmq.%s=%s" % (name, value)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_constants.py

示例15: test_removed

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import zmq_version_info [as 别名]
def test_removed(self):
        zmq_version = zmq.zmq_version_info()
        for version, new_names in constant_names.removed_in.items():
            should_have = zmq_version < version
            for name in new_names:
                try:
                    value = getattr(zmq, name)
                except AttributeError:
                    if should_have:
                        self.fail("AttributeError: zmq.%s" % name)
                else:
                    if not should_have:
                        self.fail("Shouldn't have: zmq.%s=%s" % (name, value)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_constants.py


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