Merge "Make Connection a context manager"

This commit is contained in:
Zuul 2018-10-30 17:13:38 +00:00 committed by Gerrit Code Review
commit d424169adc
1 changed files with 6 additions and 0 deletions

View File

@ -371,3 +371,9 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta,
def close(self):
"""Release any resources held open."""
self.task_manager.stop()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()