-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello! I found a bug in driver/cluster.py, which happend when using coroutines to send requests to gremlin-server. The impact is that redundant GremlinServers and its hosts will be established.
async def get_connection(self, hostname=None):
"""
**coroutine** Get connection from next available host in a round robin
fashion.
:returns: :py:class:`Connection<aiogremlin.driver.connection.Connection>`
"""
if not self._hosts:
await self.establish_hosts()
if hostname:
try:
host = self._hostmap[hostname]
except KeyError:
raise exception.ConfigError(
'Unknown host: {}'.format(hostname))
else:
host = self._hosts.popleft()
conn = await host.get_connection()
self._hosts.append(host)
return conn
When self._hosts.popleft(), the variable host could be empty, which lead to other coroutines found that not self._hosts is True and establish a new one. Moving self._hosts.append(host) ahead of conn = await host.get_connection() can fix it.
Metadata
Metadata
Assignees
Labels
No labels