异步编程报错:Task exception was never retrieved ... RuntimeError: Session is closed

Posted _刘文凯_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了异步编程报错:Task exception was never retrieved ... RuntimeError: Session is closed相关的知识,希望对你有一定的参考价值。

在执行aiohttp时:Task exception was never retrieved

future: <Task finished name=‘Task-3’ coro=<get_url() done, defined at C://async_get.py:52> exception=RuntimeError(‘Session is closed’)>
Traceback (most recent call last):
raise RuntimeError(“Session is closed”)
RuntimeError: Session is closed

解决:

下列代码报错

	asyncio.run(main())

更改为:

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())


如果有更好的方法,欢迎留言…

以上是关于异步编程报错:Task exception was never retrieved ... RuntimeError: Session is closed的主要内容,如果未能解决你的问题,请参考以下文章

Myeclipse打开后报错Could not create the view: An unexpected exception was thrown.

Ajax使用formdata异步上传文件,报错the request was rejected because no multipart boundary was found

Error: Exception was raised when calling event-notify

WAS Server 启动报错无法找到秘钥解决办法

Unity 之 切换语言导致报错:System.FormatException:String was not recognized as a valid DateTime.

基于任务的异步编程(Task,async,await)