代码之家  ›  专栏  ›  技术社区  ›  Pablo

在co例程中从pudb启动IPython交互式shell失败

  •  0
  • Pablo  · 技术社区  · 5 年前

    我真的很喜欢 pudb IPython 我已经 多年来成功调试python代码。

    # test1.py
    import time
    
    def do_something():
        import pudb
        pudb.set_trace()
    
        sleep(1)
        return 1
    
    do_something()
    

    如果你执行 python test1.py ,开始时按 ! 这个

    但是,如果你在一个共同例程中设置了一个跟踪,pudb就会毫无问题地启动, 你甚至可以踏进 await some_async_call() 要启动交互式shell并按 ! 有一个错误。福克斯示例:

    # test2.py
    import asyncio
    
    async def do_something():
        import pudb
        pudb.set_trace()
    
        await asyncio.sleep(1)
    
        return 1
    
    asyncio.run(do_something())
    
    $ python test2.py
    
    pudb starts and halts before await asyncio.sleep(1), now press !
    
    Hit Ctrl-D to return to PuDB.
    
    In [1]:
    Traceback (most recent call last):
      File "test2.py", line 11, in <module>
        asyncio.run(do_something())
      File "/home/shaoran/anaconda/py3/envs/ivct/lib/python3.8/asyncio/runners.py", line 43, in run
        return loop.run_until_complete(main)
      File "/home/shaoran/anaconda/py3/envs/ivct/lib/python3.8/asyncio/base_events.py", line 599, in run_until_complete
        self.run_forever()
      File "test2.py", line 7, in do_something
        await asyncio.sleep(1)
      File "test2.py", line 7, in do_something
        await asyncio.sleep(1)
    ...
      File "/home/shaoran/anaconda/py3/envs/ivct/lib/python3.8/asyncio/base_events.py", line 554, in run_forever
        raise RuntimeError('This event loop is already running')
    RuntimeError: This event loop is already running
    Task was destroyed but it is pending!
    task: <Task pending name='Task-5' coro=<Renderer.wait_for_cpr_responses.<locals>.wait_for_timeout() running at /home/shaoran/anaconda/py3/envs/ivct/lib/python3.8/site-packages/prompt_toolkit/renderer.py:505> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fe05cd42fd0>()]>>
    

    我怀疑这是IPython的问题,因为如果我将shell从 IPython到 bpython 然后按 ,然后启动bpython交互式shell 没有问题。我一直在寻找解决办法,但似乎 请求github #12028 , #12140 #12141 , 这似乎与此有关,但我不知道是不是真的,或者是否

    所以我的问题是:有人能重现这个错误吗?这是布丁还是伊普顿 错误?

    我使用从anaconda4.8.3(linux 64位)和IPython安装的python3.8.1 7.13.0(安装 conda install ipython -c conda-forge 通过安装时适用 pip ).

    0 回复  |  直到 5 年前