[Scons-users] Suggestions for using MP Mutex during Action phase of build

Mats Wichmann mats at wichmann.us
Sat Jan 30 10:26:07 EST 2021

On 1/29/21 10:52 PM, Manohar Reddy wrote:
> Hi Bill,
> Thanks for your prompt response.
> We run multiple builds in parallel in different processes. Would calling 
> SideEffect() from one build in one process prevent mutual access to a 
> file from other builds running in separate processes?


>         Example usage:
>         env.AcquireMPMutex("foo_file")
>         if not os.exists("foo.file"):
>              env.FooBuilder("foo.file", "foo.source")
>         env.ReleaseMPMutex("foo_file")
>         But, this is currently not working for the action phase of the
>         build. 

As I guess you've seen, this isn't really of any use, as these 
instructions will take place during the SConscript reading phase, when 
no file building takes place. SCons uses its time in this phase to build 
up the complete dependency graph, before starting the build phase, where 
a component called the Taskmaster walks this graph and enqueues and 
fires off the individual build jobs (consisting of one or more actions) 
as they become eligible to build. You're going to have to reach inside 
SCons/Executor.py to find where the actions are actually executed - and 
this is very internal not-public-API type code.  This probably isn't 
ideal - there's already Python's own (per-process) Global Interpreter 
Lock and you're going to add another level of locking, but only you know 
the scope of the problem you need to solve....

More information about the Scons-users mailing list