RuntimeError: Cannot send a request, as the client has been closed.
Opened this issue · 4 comments
Deleted user commented
Описание проблемы
кусок кода:
@dp.message_handler(state=Form.lesson)
async def process_lesson(message: types.Message, state: FSMContext):
await ns.login(
NS_LOGIN,
NS_PASSWORD,
NS_SCHOOL
)
async with state.proxy() as data:
data['lesson'] = message.text
diary = await ns.diary(
start=data['date'],
end=data['date']
)
lesson = None
lessons = diary.schedule[0].lessons
await ns.logout()
for k, v in lesson_aliases.items():
if data['lesson'] in v:
for i in lessons:
if i.subject == k:
lesson = i
break
await message.reply(lesson)
await state.finish()
ошибка:
Traceback (most recent call last):
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 417, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 238, in process_updates
return await asyncio.gather(*tasks)
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 259, in process_update
return await self.message_handlers.notify(update.message)
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/home/ubuntu/snvmk-bot-py/main.py", line 72, in process_lesson
await ns.login(
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/netschoolapi/netschoolapi.py", line 41, in login
response_with_cookies = await self._client.get('logindata')
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/httpx/_client.py", line 1740, in get
return await self.request(
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/httpx/_client.py", line 1494, in request
response = await self.send(
File "/home/ubuntu/snvmk-bot-py/.venv/lib/python3.9/site-packages/httpx/_client.py", line 1572, in send
raise RuntimeError("Cannot send a request, as the client has been closed.")
RuntimeError: Cannot send a request, as the client has been closed.
Шаги, чтобы воспроизвести проблему
- запустить аиограм-бота
- дать команду
- дать команду во второй раз
- получить ошибку
Каков ожидаемый результат?
- повторное удачное выполнение команды
Каков реальный результат?
- ошибка
Дополнительные детали / скриншот
- используется в aiogram-боте
lentryd commented
А какая у тебя версия питона?
Deleted user commented
А какая у тебя версия питона?
последний 3.9 с репов ubuntu server, ща sshнусь гляну точно
Deleted user commented
А какая у тебя версия питона?
3.9.5
Deleted user commented
а все, крч в самом хандлере сообщения теперь создаю обьект NetSchoolAPI, работает)