本文整理汇总了Python中zmq.SNDHWM属性的典型用法代码示例。如果您正苦于以下问题:Python zmq.SNDHWM属性的具体用法?Python zmq.SNDHWM怎么用?Python zmq.SNDHWM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类zmq
的用法示例。
在下文中一共展示了zmq.SNDHWM属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_hwm
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [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)
示例2: get_hwm
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [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)
示例3: set_hwm
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [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)
示例4: createZMQSocket
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [as 别名]
def createZMQSocket(self, sock_type):
"""Create a socket of the given sock_type and deactivate message dropping"""
sock = self.ZMQcontext.socket(sock_type)
sock.setsockopt(zmq.LINGER, LINGER_TIME)
sock.setsockopt(zmq.IPV4ONLY, 0)
# Remove message dropping
sock.setsockopt(zmq.SNDHWM, 0)
sock.setsockopt(zmq.RCVHWM, 0)
try:
sock.setsockopt(zmq.IMMEDIATE, 1)
except:
# This parameter was recently added by new libzmq versions
pass
# Don't accept unroutable messages
if sock_type == zmq.ROUTER:
sock.setsockopt(zmq.ROUTER_MANDATORY, 1)
return sock
示例5: set_hwm
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [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)
示例6: init_communication
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import SNDHWM [as 别名]
def init_communication(self):
"""Initialize sockets for communication."""
ctx = zmq.Context()
# Socket to send updated network parameters to worker
self.pub_socket = ctx.socket(zmq.PUB)
self.pub_socket.setsockopt(zmq.SNDHWM, 2)
self.pub_socket.bind(f"tcp://127.0.0.1:{self.comm_cfg.learner_worker_port}")
# Socket to receive replay data and send new priorities to buffer
self.rep_socket = ctx.socket(zmq.REP)
self.rep_socket.bind(f"tcp://127.0.0.1:{self.comm_cfg.learner_buffer_port}")
# Socket to send logging data to logger
self.push_socket = ctx.socket(zmq.PUSH)
self.push_socket.connect(f"tcp://127.0.0.1:{self.comm_cfg.learner_logger_port}")