Use pdb.set_trace() in a script that reads stdin via a pipe

前端 未结 6 1588
我寻月下人不归
我寻月下人不归 2020-12-05 04:20

I have a python script that reads stdin via a pipe, and I cannot seem to use it with pdb.set_trace().

my_script.py:

#!/usr/bin/env python
import sy         


        
6条回答
  •  无人及你
    2020-12-05 04:53

    The thing is: cat will not stop sending data because your script is currently debugging. And when you going to trace, then stdin is still filled by cat + your keyboard. You need to choose one of them.

    You can read the whole stdin, and then, set_trace() will be not filled by stdin:

    sys.stdin.read()
    pdb.set_trace()
    

提交回复
热议问题