avoid connection leaks (#80532)

In case TaskExecutor needs to open a new connection it should attempt to
properly dispose existing one if any.

fixes: #80532
pull/80787/head
Ondrej Balaz 3 years ago
parent 0830b69059
commit d7967948d3

@ -578,6 +578,14 @@ class TaskExecutor:
# pc compare, left here for old plugins, but should be irrelevant for those
# using get_option, since they are cleared each iteration.
self._play_context.remote_addr != self._connection._play_context.remote_addr):
# attempt to close existing connection if any
if self._connection:
try:
self._connection.close()
except AttributeError:
pass
except Exception as e:
display.debug(u"error closing connection: %s" % to_text(e))
self._connection = self._get_connection(cvars, templar, current_connection)
else:
# if connection is reused, its _play_context is no longer valid and needs

Loading…
Cancel
Save