Search code examples
pythontestingnumactl

pysys startProcess with numactl


numactl is a process which can set processor affinity. it takes the process in which to pin to a cpu as a parameter:

numactl -physcpubind 0 <process> <args>

I can successfully run my process using the pysys startProcess command:

BaseTest.startProcess('processA argsA') 

However the below causes a defunct python process according to ps -ef [PID].

BaseTest.startProcess('numactl -physcpubind 0 processA argsA') 

Any thoughts on how startProcess() can be used to call a process (numactl) which:

  • itself has arguments (-physcpubind 0)
  • one of said arguments is another process (processA), which itself has arguments (argsA)

TIA


Solution

  •  def startProcess(self, command, arguments, environs=None, workingDir=None, state=FOREGROUND,
                        timeout=TIMEOUTS['WaitForProcess'], stdout=None, stderr=None, displayName=None,
                        abortOnError=None, ignoreExitStatus=True):
    

    The command argument to startProcess is the actual executable you want to launch, which in this case is numactl. Hence any call to startProcess should at lease be of the form;

    startProcess(command='numactl', arguments=...)
    

    So the question really is what are the arguments you pass. I don't have a linux environment handy to confirm but I would expect one of the following i.e.

    arguments=['-physcpubind', '0', 'processA', 'argsA']
    arguments=['-physcpubind', '0', 'processA argsA']
    

    The first means that generally numactl treats the process to run and its command line arguments as individual arguments to itself, or the latter means that numactl treat the process and its arguments to run as a single argument to itself. It's worth trying both out to see what happens.