diff --git a/bard/bard.py b/bard/bard.py index a4510f4..cc03b32 100644 --- a/bard/bard.py +++ b/bard/bard.py @@ -40,8 +40,9 @@ async def _get_session(self, force_close: bool = False) -> ClientSession: "__Secure-1PSIDTS": self.secure_1psidts, } - if self.session and force_close: + if self.session and not self.session.closed and force_close: await self.session.close() + self.session = None if not self.session: self.session = ClientSession( @@ -144,6 +145,7 @@ async def close_conversation(self) -> None: """ if self.session and not self.session.closed: await self.session.close() + self.session = None self.conversation_id = None self.response_id = None