Пытаюсь передать сессию между функциями в python, но происходит ошибка:
Exception has occurred: RuntimeError
Session is closed
File "C:\Users\Maxim\Desktop\connserv.py", line 31, in edit_db
async with client.get(url=url, params=params) as resp:
File "C:\Users\Maxim\Desktop\connserv.py", line 43, in <module>
asyncio.run(edit_db())
Код который я использую:
from aiohttp import ClientSession, client
import asyncio
async def send_request():
url = ''
params = {
'email': "",
"pass": "",
"authorization": "true"
}
async with ClientSession() as client:
async with client.post(url, params=params) as resp:
return client
async def edit_db():
client = await send_request()
url = ''
params = {
"ID": "248098",
"data[name]": "Statistics [ Global Timezones Bot ]",
"data[text]": f"""reefe""",
"action": "edit_record",
"data[category_ID]": "82627"
}
async with client.post(url=url, params=params) as resp:
print(resp.text)
if __name__ == "__main__":
asyncio.run(edit_db())