Skip to content

Commit

Permalink
Clear PoolManager in ‘remote_connection’ to ensure sockets are closed
Browse files Browse the repository at this point in the history
A fix for: #6878

When the ‘keep alive’ option is enabled the remote_connection object will create a PoolManager, but never deliberately clear it.  This can cause ResourceWarning warnings from open sockets.

Added a new "close()" function which explicitly clears the pool.  This close function is called from Webdriver's “quit()” function (+1 squashed commit)
  • Loading branch information
GQAssurance authored and AutomatedTester committed Feb 19, 2019
1 parent 4c41c3d commit eb4a3c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,10 @@ def _request(self, method, url, body=None):
finally:
LOGGER.debug("Finished Request")
resp.close()

def close(self):
"""
Clean up resources when finished with the remote_connection
"""
if hasattr(self, '_conn'):
self._conn.clear()
1 change: 1 addition & 0 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def quit(self):
self.execute(Command.QUIT)
finally:
self.stop_client()
self.command_executor.close()

@property
def current_window_handle(self):
Expand Down

0 comments on commit eb4a3c4

Please sign in to comment.