zoukankan      html  css  js  c++  java
  • 【Jupyter】异步RuntimeError: asyncio.run() cannot be called from a running event loop

    问题:在jupyter notebook中使用asyncio.run()时发生如上标题报错,没错就是这个

     官方文档:This function cannot be called when another asyncio event loop is running in the same thread.

    百度翻译:当另一个异步事件循环在同一线程中运行时,无法调用此函数

    大致就是jupyter 已经运行了loop,无需自己激活,采用上文中的await()调用即可

    In jupyter

    async def main():
            print(1)
    await main()

    In plain Python (≥3.7)

    import asyncio
    async def main():
        print(1)
    asyncio.run(main())

    链接: 原文

    参考:https://blog.csdn.net/sunnydarkcloud/article/details/101775608

    ------------------------------- ********厚德达理,励志勤工******** -------------------------------
  • 相关阅读:
    使用Python操作MySQL数据库
    SQL server数据库语句
    SQL server数据库
    实施工程师
    Vue外卖项目
    每日思考记录(12)
    Vue核心知识点
    jQuery快速入门
    js
    css2
  • 原文地址:https://www.cnblogs.com/hightech/p/13855002.html
Copyright © 2011-2022 走看看