Forráskód Böngészése

fix an error in cookbook

wangweimin 3 éve
szülő
commit
99593db468
1 módosított fájl, 3 hozzáadás és 2 törlés
  1. 3 2
      docs/cookbook.rst

+ 3 - 2
docs/cookbook.rst

@@ -211,11 +211,12 @@ The following code shows how to redirect stdout of python code and subprocess to
         process = subprocess.Popen("ls -ahl", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
         while True:
             output = process.stdout.readline()
-            if output == '' and process.poll() is not None:
-                break
             if output:
                 put_text(output.decode('utf8'), inline=True)
 
+            if not output and process.poll() is not None:
+                break
+
 
 Add missing syntax highlight for code output
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^