Ability to set LINGER when creating RPC connections
Closed this issue · 1 comments
Setting the transport's zmq.LINGER
option only applies to newly created sockets, which is not the case for RPC connections where socket creation is done inside create_zmq_connection()
called by serve_rpc()
or connect_rpc()
.
It works as expected if I change to serve_rpc()
and connect_rpc()
to use pre-existing zmq sockets like this, but there seems no way to set it without modifying aiozmq:
@asyncio.coroutine
def serve_rpc(handler, *, connect=None, bind=None, loop=None,
translation_table=None, log_exceptions=False,
exclude_log_exceptions=(), timeout=None):
...
ctx = zmq.Context.instance()
sock = ctx.socket(zmq.ROUTER) # duplicate with below call
sock.setsockopt(zmq.LINGER, 50) # need some way to generalize this part
transp, proto = yield from create_zmq_connection(
lambda: _ServerProtocol(loop, handler,
translation_table=translation_table,
log_exceptions=log_exceptions,
exclude_log_exceptions=exclude_log_exceptions,
timeout=timeout),
zmq.ROUTER, connect=connect, bind=bind, zmq_sock=sock, loop=loop)
return Service(loop, proto)
We just could add yet-another keyword argument such as linger
to servce_rpc()
and connect_rpc()
, but it seems not very clean. If we add zmq_sock
argument like in create_zmq_connection()
, then there will be duplicates of settings socket types inside/outside aiozmq. Maybe, we could add a global default socket option table in the aiozmq.rpc
module level that can be set in prior to calling serve_rpc()
or connect_rpc()
.
What are your thoughts on setting socket options for aiozmq.rpc
?
Ooops, I found that I was confused with my prior experiences...
Settings transport's linger option works after serve_rpc()
or connect_rpc()
actually!
Sorry for bothering you.