Run pdb without stdin/stdout using FIFO

后端 未结 3 1785
滥情空心
滥情空心 2020-12-10 08:33

I am developing FUSE filesystem with python. The problem is that after mounting a filesystem I have no access to stdin/stdout/stderr from my fuse script. I don\'t see anythi

相关标签:
3条回答
  • 2020-12-10 08:47

    Ok. Exactly what I want, has been done in http://pypi.python.org/pypi/rpdb/0.1.1 .

    0 讨论(0)
  • 2020-12-10 08:51

    I just ran into a similar issue in a much simpler use-case:

    • debug a simple Python program running from the command line that had a file piped into sys.stdin, meaning, no way to use the console for pdb.

    I ended up solving it by using wdb.

    Quick rundown for my use-case. In the shell, install both the wdb server and the wdb client:

    pip install wdb.server wdb
    

    Now launch the wdb server with:

    wdb.server.py
    

    Now you can navigate to localhost:1984 with your browser and see an interface listing all Python programs running. The wdb project page above has instructions on what you can do if you want to debug any of these running programs.

    As for a program under your control, you can you can debug it from the start with:

    wdb myscript.py --script=args < and/stdin/redirection
    

    Or, in your code, you can do:

    import wdb; wdb.set_trace()
    

    This will pop up an interface in your browser (if local) showing the traced program.

    Or you can navigate to the wdb.server.py port to see all ongoing debugging sessions on top of the list of running Python programs, which you can then use to access the specific debugging session you want.

    Notice that the commands for navigating the code during the trace are different from the standard pdb ones, for example, to step into a function you use .s instead of s and to step over use .n instead of n. See the wdb README in the link above for details.

    0 讨论(0)
  • 2020-12-10 09:07

    Before starting the python app

    mkfifo pdb.in
    mkfifo pdb.out
    

    Then when pdb is called you can interact with it using these two cat commands, one running in the background

    cat pdb.out & cat > pdb.in
    

    Note the readline support does not work (i.e. up arrow)

    0 讨论(0)
提交回复
热议问题