本文整理匯總了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}")