Skip to content

Commit

Permalink
Added __del__ method on Connection Class to close any open sessions.
Browse files Browse the repository at this point in the history
As suggested in googleapis#151.
  • Loading branch information
Alejandro Casanovas committed Feb 4, 2019
1 parent ad409ff commit 88e1059
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions O365/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,16 @@ def _delete_token(self, token_path=None):
warnings.warn('This method is deprecated. Use a TokenBackend instead.', DeprecationWarning)
return False

def __del__(self):
"""
Clear the session by closing it
This should be called manually by the user "del account.con"
There is no guarantee that this method will be called by the garbage collection
But this is not an issue because this connections willbe automatically closed.
"""
if self.session:
self.session.close()


def oauth_authentication_flow(client_id, client_secret, scopes=None,
protocol=None, **kwargs):
Expand Down

0 comments on commit 88e1059

Please sign in to comment.