mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
destroy_temp_session is awaitable
This commit is contained in:
parent
f047bb6db3
commit
9e97cd6727
2 changed files with 4 additions and 4 deletions
|
|
@ -110,7 +110,7 @@ class BaseBot:
|
||||||
self._temp_sessions.append(session)
|
self._temp_sessions.append(session)
|
||||||
return session
|
return session
|
||||||
|
|
||||||
def destroy_temp_session(self, session: aiohttp.ClientSession):
|
async def destroy_temp_session(self, session: aiohttp.ClientSession):
|
||||||
"""
|
"""
|
||||||
Destroy temporary session
|
Destroy temporary session
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ class BaseBot:
|
||||||
:type session: :obj:`aiohttp.ClientSession`
|
:type session: :obj:`aiohttp.ClientSession`
|
||||||
"""
|
"""
|
||||||
if not session.closed:
|
if not session.closed:
|
||||||
session.close()
|
await session.close()
|
||||||
if session in self._temp_sessions:
|
if session in self._temp_sessions:
|
||||||
self._temp_sessions.remove(session)
|
self._temp_sessions.remove(session)
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ class BaseBot:
|
||||||
dest.seek(0)
|
dest.seek(0)
|
||||||
return dest
|
return dest
|
||||||
finally:
|
finally:
|
||||||
self.destroy_temp_session(session)
|
await self.destroy_temp_session(session)
|
||||||
|
|
||||||
async def send_file(self, file_type, method, file, payload) -> Union[Dict, base.Boolean]:
|
async def send_file(self, file_type, method, file, payload) -> Union[Dict, base.Boolean]:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ async def cmd_start(message: types.Message):
|
||||||
await bot.send_message(message.chat.id, emojize(text(*content, sep='\n')), parse_mode=ParseMode.MARKDOWN)
|
await bot.send_message(message.chat.id, emojize(text(*content, sep='\n')), parse_mode=ParseMode.MARKDOWN)
|
||||||
|
|
||||||
# Destroy temp session
|
# Destroy temp session
|
||||||
bot.destroy_temp_session(session)
|
await bot.destroy_temp_session(session)
|
||||||
|
|
||||||
# In this example you can see emoji codes: ":globe_showing_Americas:" and ":locked_with_key:"
|
# In this example you can see emoji codes: ":globe_showing_Americas:" and ":locked_with_key:"
|
||||||
# You can find full emoji cheat sheet at https://www.webpagefx.com/tools/emoji-cheat-sheet/
|
# You can find full emoji cheat sheet at https://www.webpagefx.com/tools/emoji-cheat-sheet/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue