Magnet2Torrent-RuntimeError:事件循环已关闭

时间:2020-07-13 15:31:05

标签: python torrent magnet-uri

我正在尝试使用magnet2torrent模块(https://pypi.org/project/magnet2torrent/)的(第一个)示例代码。 但是当我得到结果并且程序结束后,此错误将引发多次...

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001B549743B80>
Traceback (most recent call last):
  File "<directory>\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "<directory>\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "<directory>\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "<directory>\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

为什么会发生,我该如何解决?

示例代码:

import asyncio

from magnet2torrent import Magnet2Torrent, FailedToFetchException

async def fetch_that_torrent():
    m2t = Magnet2Torrent("magnet:?xt=urn:btih:e2467cbf021192c241367b892230dc1e05c0580e&dn=ubuntu-19.10-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")
    try:
        filename, torrent_data = await m2t.retrieve_torrent()
    except FailedToFetchException:
        print("Failed")

asyncio.run(fetch_that_torrent())

0 个答案:

没有答案