diff --git a/events/collection.py b/events/collection.py index 7f427aa..3d4d6ae 100644 --- a/events/collection.py +++ b/events/collection.py @@ -93,27 +93,27 @@ def get_event(self, name: str): return event def lookup_event_by_uid(self, uid: str): - session = requests.Session() - session.auth = self.auth - - query = f''' - - - - - - - - - {escape(uid)} - - - - - ''' - - response = session.request(url=self.url, method='REPORT', data=query) - response.raise_for_status() + with requests.Session() as session: + session.auth = self.auth + + query = f''' + + + + + + + + + {escape(uid)} + + + + + ''' + + response = session.request(url=self.url, method='REPORT', data=query) + response.raise_for_status() tree = ElementTree.fromstring(response.text)