[zmq] ZMQ_LINGER default value
Set default socket close linger value to -1, which means wait until all messages being sent. Change-Id: I52cabc268a777a6c2505098d0520669389a44766
This commit is contained in:
parent
ea204a0f6d
commit
87ff93e476
@ -58,9 +58,12 @@ zmq_opts = [
|
||||
help='Name of this node. Must be a valid hostname, FQDN, or '
|
||||
'IP address. Must match "host" option, if running Nova.'),
|
||||
|
||||
cfg.IntOpt('rpc_cast_timeout', default=30,
|
||||
cfg.IntOpt('rpc_cast_timeout', default=-1,
|
||||
help='Seconds to wait before a cast expires (TTL). '
|
||||
'Only supported by impl_zmq.'),
|
||||
'The default value of -1 specifies an infinite linger '
|
||||
'period. The value of 0 specifies no linger period. '
|
||||
'Pending messages shall be discarded immediately '
|
||||
'when the socket is closed. Only supported by impl_zmq.'),
|
||||
|
||||
cfg.IntOpt('rpc_poll_timeout', default=1,
|
||||
help='The default number of seconds that poll should wait. '
|
||||
|
@ -36,6 +36,12 @@ class ZmqSocket(object):
|
||||
self.context = context
|
||||
self.socket_type = socket_type
|
||||
self.handle = context.socket(socket_type)
|
||||
|
||||
self.close_linger = -1
|
||||
if self.conf.rpc_cast_timeout > 0:
|
||||
self.close_linger = self.conf.rpc_cast_timeout * 1000
|
||||
self.handle.setsockopt(zmq.LINGER, self.close_linger)
|
||||
|
||||
self.connections = set()
|
||||
|
||||
def type_name(self):
|
||||
@ -86,7 +92,6 @@ class ZmqSocket(object):
|
||||
return self.handle.recv_multipart(*args, **kwargs)
|
||||
|
||||
def close(self, *args, **kwargs):
|
||||
self.handle.setsockopt(zmq.LINGER, self.conf.rpc_cast_timeout * 1000)
|
||||
self.handle.close(*args, **kwargs)
|
||||
|
||||
def connect_to_address(self, address):
|
||||
|
Loading…
x
Reference in New Issue
Block a user