Я могу сгенерировать изображение с помощью matplotlib и успешно сохранить изображение, но не могу бот-диск разногласия отобразить изображение. Когда я go отображаю изображение, я получаю сообщение об ошибке в заголовке. Почему я получаю эту ошибку и как я могу go исправить ее?
Код:
async def on_message(message):
# other stuff in function including checks, etc...
msg_attach = message.attachments[0]
response = requests.get(msg_attach.url)
file_object = io.StringIO(response.content.decode('utf-8'))
df = pd.read_csv(file_object)
graph.make_graph(df) # this makes the graph and saves it in the same directory
await message.channel.send(file = discord.File('my_image.png')) # this is throwing the error
bot.run('the key')
Связанное сообщение об ошибке:
Traceback (most recent call last):
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 67, in on_message
await message.channel.send(file = discord.File('my_image.png'))
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/discord/abc.py", line 839, in send
content=content, tts=tts, embed=embed, nonce=nonce)
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/discord/http.py", line 165, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/aiohttp/client.py", line 426, in _request
with timer:
File "/Users/Brandon/anaconda3/envs/tt/lib/python3.6/site-packages/aiohttp/helpers.py", line 579, in __enter__
raise RuntimeError('Timeout context manager should be used '
RuntimeError: Timeout context manager should be used inside a task