Skip to content

Commit

Permalink
Implemented Context Manager for Requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hcwong committed Feb 3, 2020
1 parent 9f44e8f commit a444cc5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agithub/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,19 @@ def _filterEmptyHeaders(self, headers):
newHeaders[header] = headers[header]

return newHeaders

class connectionManager(object):
'''
Context manager for handling connections in client.request
'''
def __init__(self, client):
self.conn = client.get_connection()

def __enter__(self):
return self.conn

def __exit__(self, exc_type, exc_value, traceback):
self.conn.close()



0 comments on commit a444cc5

Please sign in to comment.