diff --git a/agithub/base.py b/agithub/base.py index 88b8a31..4136eb1 100644 --- a/agithub/base.py +++ b/agithub/base.py @@ -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() + + +