File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -289,7 +289,14 @@ if __name__ == "__main__":
289289## Tips and tricks
290290These are some pro-tips for working with MapReduce programs written in Python for the Hadoop Streaming interface.
291291
292- ### Debugging
292+ ### Print debug messages to ` stderr `
293+ To avoid interfering with pipeline output in ` stdout ` , direct debugging print messages to ` stderr ` :
294+
295+ ``` python
296+ print (" DEBUG finding bugs... ~(^._.)" , file = sys.stderr)
297+ ```
298+
299+ ### Debugging with PDB
293300We encounter a problem if we add a ` breakpoint() ` in ` map.py ` .
294301``` python
295302for line in sys.stdin:
@@ -299,13 +306,13 @@ for line in sys.stdin:
299306 print (f " { word} \t 1 " )
300307```
301308
302- PDB/PDB++ confuses the stdin being piped in from the input file for user input, so we get these errors:
309+ PDB confuses the stdin being piped in from the input file for user input, so we get these errors:
303310``` console
304311$ cat input/input* | ./map.py
305312...
306- (Pdb++ ) *** SyntaxError: invalid syntax
307- (Pdb++ ) *** SyntaxError: invalid syntax
308- (Pdb++ ) *** SyntaxError: invalid syntax
313+ (Pdb) *** SyntaxError: invalid syntax
314+ (Pdb) *** SyntaxError: invalid syntax
315+ (Pdb) *** SyntaxError: invalid syntax
309316...
310317```
311318
@@ -325,7 +332,7 @@ Now our debugger works correctly.
325332``` console
326333$ cat input/input* | ./map.py
327334...
328- (Pdb++ )
335+ (Pdb)
329336```
330337
331338Don't forget to remove your temporary changes!
You can’t perform that action at this time.
0 commit comments