簡體   English   中英

Python-PDB自動提高BdbQuit

[英]Python-PDB automatically raise BdbQuit

我一直在使用pdb.set_trace()在我的代碼中設置一些斷點,並且總是很流暢。

我有一個在循環內運行python腳本的shell腳本:

cat $file1 | (
#read something from file1
while ... 
do
   if ... then
      cat $file2 | (
      # read something from file2
      while ...
          do 
               python test.py
               # read something from file2
          done)
   fi
   #read something from file1
done)

假設test.py只是一個簡單的hello世界。 我將pdb.set_trace()放入我的python腳本中。 當我在循環外運行代碼時,只需通過python test.py,一切正常。 但是,當我執行.sh腳本時,它到達pdb.set_trace()的那一刻,它會引發一個BdbQuit和我的python腳本。

我不知道是什么問題。 如果有人可以幫助我解決這個問題,我將非常感激。

謝謝。

您正在while循環內重定向stdin

cat $file1 | while ...

交互式pdb提示符也從stdin讀取,但是由於已被重定向,因此它將僅從該文件中獲取輸入。

在這種情況下,最簡單的解決方案就是使用remote-pdb之類的東西,它可以打開網絡連接,您可以使用telnetnc連接到該網絡連接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM