(RuntimeError: Form data has been processed already) What does it mean?

(RuntimeError: Form data has been processed already) What does it mean?

我正在开发一个需要发送文件的 discord 机器人。从以前的文件发送情况中我能想到的唯一对我有用的变化是文件的编码是 ISO-8859-1 而不是 utf-8。我用 with open(filepath,'r',encoding='ISO-8859-1') as mp3 创建了 TextIO 对象,然后在那个下面,我使用了 await channel.send(file=discord.File(mp3))(在后来的测试中,即使我将 discord.File 调用移到另一行,错误在发送方法中).代码的发送行有一个巨大的错误链,以 RuntimeError: Form data has been processed already 结尾。这个错误在我的上下文中意味着什么,我该怎么做才能修复它?提前致谢!

作为参考,这里是完整的异常链:

    await coro(*args, **kwargs)
  File "/Users/nathanwolf/Documents/coding/PycharmProjects/lyrics bot/main.py", line 75, in on_message
    await message.channel.send(file=discord.File(mp3))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/abc.py", line 915, in send
    data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 185, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client.py", line 492, in _request
    req = self._request_class(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 313, in __init__
    self.update_body_from_data(data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 507, in update_body_from_data
    body = body()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/formdata.py", line 168, in __call__
    return self._gen_form_data()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/formdata.py", line 132, in _gen_form_data
    raise RuntimeError("Form data has been processed already")
RuntimeError: Form data has been processed already```

我修复了它,但还不完全清楚我是如何修复的。更新 discord.py 有效,但是当我尝试将 mp3 文件的编码更改为 utf-8 以便 discord 可以读取它时,错误又回来了。我通过不给 discord.File() 方法一个 TextIO 对象而是给它文件名来绕过它。不知何故奏效了。