[issue6409] 2to3 generates malformed diffs

STINNER Victor report at bugs.python.org
Sun Jan 31 03:05:45 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

I'm able to reproduce the bug. The problem is that "-j 4" option creates 4 working processes, and they are all writing to stdout at the same time.

Main process: main() => refactor() => refactor_file() sends tasks to child processes
Children: _child() => queue.get ~> refactor_file() => processed_file() => print_output() writes the diff to stdout using print()

A solution would be to use a lock to ensure that only one process is writing to stdout at the same time... But we may loose all advantages of using different Python processes, it's a new kind of GIL :)

A better solution would be to send output (the whole diff for one file) to the main process which will be the only process writing the stdout. I don't know multiprocessing enough to propose a patch.

Note: flush() in each child process doesn't ensure that no process is writing to stdout at the same time.

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6409>
_______________________________________


More information about the Python-bugs-list mailing list