Wrapper to ensure that all processes execute together
507486
def _lockstep_fcn(values):
    
    numrequired, fcn, args = values
    with _process_lock:
        _numdone.value += 1
    # yep this is an ugly busy loop, do something better please
    # when we care about the performance of this call and not just the
    # guarantee it provides (ok... maybe never)
    while 1:
        if _numdone.value == numrequired:
            return fcn(args)
644278
def execute(self):
        """"""
        if self._decode_output:
            # Capture and decode system output
            with Popen(self.command, shell=True, stdout=PIPE) as process:
                self._output = [i.decode("utf-8").strip() for i in process.stdout]
                self._success = True
        else:
            # Execute without capturing output
            os.system(self.command)
            self._success = True
        return self
95264
def run_in_process_pool(self, pool_size=None, func=None, *args):
        """"""
        executor = ProcessPool(pool_size)
        return self.loop.run_in_executor(executor, func, *args)
1136033
def __wrap_docker_exec(func):
    ''''''
    def call(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except OSError as e:
            if e.errno == errno.ENOENT:
                raise DockerExecuteError('Failed to execute docker. Is it installed?')
            raise
    return call
1220889
def check_output(*args, **kwargs):
    ''''''
    if hasattr(subprocess, 'check_output'):
        return subprocess.check_output(stderr=subprocess.STDOUT, universal_newlines=True,
                                       *args, **kwargs)
    else:
        process = subprocess.Popen(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                                   universal_newlines=True, **kwargs)
        output, _ = process.communicate()
        retcode = process.poll()
        if retcode:
            error = subprocess.CalledProcessError(retcode, args[0])
            error.output = output
            raise error
        return output
888075
def all(self, timeout=None, max_concurrency=64, auto_batch=True):
        
        return self.fanout('all', timeout=timeout,
                           max_concurrency=max_concurrency,
                           auto_batch=auto_batch)
460549
private void checkStdinCloses()
   {
      List<OsxProcess> processes = new ArrayList<>();
      // drainTo() is known to be atomic for ArrayBlockingQueue
      closeQueue.drainTo(processes);
      for (OsxProcess process : processes) {
         process.getStdin().close();
      }
   }
805685
def launch_processes(tests, run_module, group=True, **config):
    
    manager = multiprocessing.Manager()
    test_summaries = manager.dict()
    process_handles = [multiprocessing.Process(target=run_module.run_suite,
                       args=(test, config[test], test_summaries)) for test in tests]
    for p in process_handles:
        p.start()
    for p in process_handles:
        p.join()

    if group:
        summary = run_module.populate_metadata(tests[0], config[tests[0]])
        summary["Data"] = dict(test_summaries)
        return summary
    else:
        test_summaries = dict(test_summaries)
        summary = []
        for ii, test in enumerate(tests):
            summary.append(run_module.populate_metadata(test, config[test]))
            if summary[ii]:
                summary[ii]['Data'] = {test: test_summaries[test]}
        return summary
658285
def flushall(self, asynchronous=False):
        
        args = []
        if asynchronous:
            args.append(Token.get_token('ASYNC'))
        return self.execute_command('FLUSHALL', *args)
152170
def submit_comp_job(self, path, callback, method, *args, **kwargs):
        """"""
        if self.executor is None:
            with self.handling_exceptions():
                callback(getattr(self.comp, method)(*args, **kwargs))
        else:
            path = showpath(path)
            with logger.in_path(path):  # pickle the compiler in the path context
                future = self.executor.submit(multiprocess_wrapper(self.comp, method), *args, **kwargs)

            def callback_wrapper(completed_future):
                """Ensures that all errors are always caught, since errors raised in a callback won't be propagated."""
                with logger.in_path(path):  # handle errors in the path context
                    with self.handling_exceptions():
                        result = completed_future.result()
                        callback(result)
            future.add_done_callback(callback_wrapper)
52097
def ensure_output(self):
        
        if not os.path.exists(self.output):
            os.makedirs(self.output)
1271566
def celery_enable_all():
    """"""
    from celery.signals import task_prerun, task_postrun, task_failure
    task_prerun.connect(prerun_handler)
    task_postrun.connect(postrun_handler)
    # Also have to cleanup on failure.
    task_failure.connect(postrun_handler)
137155
def system(*args, **kwargs):
    """"""
    kwargs.setdefault('stdout', subprocess.PIPE)
    proc = subprocess.Popen(args, **kwargs)
    out, _ = proc.communicate()
    if proc.returncode:
        raise SystemExit(proc.returncode)
    return out.decode('utf-8')
640443
def flush_all(self, conn):
        """"""
        command = b'flush_all\r\n'
        response = yield from self._execute_simple_command(
            conn, command)

        if const.OK != response:
            raise ClientException('Memcached flush_all failed', response)
221046
def execute(self, *, args: Union[list, tuple], options: dict) -> tuple:
        ''''''
        cmd = self._build_cmd(args)
        process = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE,
                                   encoding='utf-8', shell=options.get('shell', False), env=options.get('env'))
        return process
383968
def run(self):
        '''
        
        '''
        salt.utils.process.appendproctitle(self.name)
        self.clear_funcs = ClearFuncs(
           self.opts,
           self.key,
           )
        self.aes_funcs = AESFuncs(self.opts)
        salt.utils.crypt.reinit_crypto()
        self.__bind()
1021318
def execute(self, command):
        """"""
        process = subprocess.Popen(
            command,
            preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL)
        )
        return process