Skip to content

Commit c94b113

Browse files
committed
Improve getting iproto port for tarantool < 2.4.1
This patch improves getting the iproto port for tarantool < 2.4.1. The previous revision of the lua script might give unstable result (more than 1 port) and test-run failed. Now it is fixed. Follows up #141
1 parent 4bac867 commit c94b113

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/tarantool_server.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,11 +1315,20 @@ def get_iproto_port(self):
13151315
end
13161316
end
13171317
end
1318-
if #res ~= 1 then
1318+
local l_sockets = {{}}
1319+
local con_timeout = 0.1
1320+
for i, s in ipairs(res) do
1321+
con = socket.tcp_connect(s.host, s.port, con_timeout)
1322+
if con then
1323+
con:close()
1324+
table.insert(l_sockets, s)
1325+
end
1326+
end
1327+
if #l_sockets ~= 1 then
13191328
error(("Zero or more than one listening TCP sockets: %s")
1320-
:format(#res))
1329+
:format(#l_sockets))
13211330
end
1322-
return {{host = res[1].host, port = res[1].port}}
1331+
return {{host = l_sockets[1].host, port = l_sockets[1].port}}
13231332
end
13241333
""".format(localhost=self.localhost)
13251334
res = yaml.safe_load(self.admin(script, silent=True))[0]

0 commit comments

Comments
 (0)