Работаю с сокетами и по ним отправляю файл в бота, но возникает ошибка
Traceback (most recent call last):
File "c:\Users\Professional\Desktop\own_botnet\server.py", line 40, in on_client
asyncio.run(bot.send_document(id, document=InputFile(logs, filename="logs.txt")))
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
return future.result()
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\bot.py", line 708, in send_document
result = await self.request(api.Methods.SEND_DOCUMENT, payload, files)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\base.py", line 231, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 139, in make_request
async with session.post(url, data=req, **kwargs) as response:
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 1138, in __aenter__
self._resp = await self._coro
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 466, in _request
with timer:
File "C:\Users\Professional\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\helpers.py", line 701, in __enter__
raise RuntimeError(
RuntimeError: Timeout context manager should be used inside a task
код:
data = connection.recv(12400).decode("utf-8")
command = data.split(' ', maxsplit=1)[0]
if command == "logs":
logs = BytesIO(bytes(data.split(' ', maxsplit=1)[1], encoding="utf-8"))
asyncio.run(bot.send_document(id, document=InputFile(logs, filename="logs.txt")))
Насколько я понял оно требует запускать в основном потоке, но такой возможности у меня нет