[Scons-users] SCONS -j12, console output is disordered

Mats Wichmann mats at wichmann.us
Sat Dec 23 11:50:50 EST 2023


On 12/23/23 08:39, Yu,Zhiwei (YFI,Shanghai,CN) via Scons-users wrote:
> Hi Guys,
> 
>       I add -j12 param, then the console output is disordered.
>       I wonder that the reason is python's print function is not 
> thread-safe or atomic operation, right?
>       How could I fix the problem when I use SCONS.

There are two sources of output:

(1) scons-generated (by default, the command line, modifiable by setting 
the various COMSTR variables, or setting up a PRINT_CMD_LINE_FUNC). 
This text should not have any particular interleave problems.
(2) command-issued output.  This you can't do much about, because SCons 
isn't really designed for that.  As jobs are classified as ready to run, 
they're put on the queue; meanwhile when a job runner slot opens up, 
it's assigned a job from the queue. Those are run as subprocesses, and 
run independently; SCons doesn't collect their output or any other 
information besides the exit status.  So you're just seeing the effect 
of having 12 job runner slots all firing off jobs as they become 
available - if those generate their own output that can well interleave.

To not have interleaved command output, you'd need to convince SCons to 
collect the output of the subprocesses rather than going to the default 
stdout/stderr.  That is possible, but beyond the scope of a first answer.



More information about the Scons-users mailing list