'Parallel audit loop'

def audit_loop(self, parent, zbo_fps, override_devices=None, **kwargs):

    self.clear_recon_cache('ALL')
    self.clear_recon_cache('ZBF')
    once = (kwargs.get('mode') == 'once')
    kwargs['device_dirs'] = override_devices
    if parent:
        kwargs['zero_byte_fps'] = zbo_fps
        self.run_audit(**kwargs)
    else:
        pids = set()
        if self.conf_zero_byte_fps:
            zbf_pid = self.fork_child(zero_byte_fps=True, **kwargs)
            pids.add(zbf_pid)
        if (self.concurrency == 1):
            pids.add(self.fork_child(**kwargs))
        else:
            parallel_proc = ((self.concurrency + 1) if self.conf_zero_byte_fps else self.concurrency)
            device_list = (list(override_devices) if override_devices else listdir(self.devices))
            shuffle(device_list)
            while device_list:
                pid = None
                if (len(pids) == parallel_proc):
                    pid = os.wait()[0]
                    pids.discard(pid)
                if (self.conf_zero_byte_fps and (pid == zbf_pid) and once):
                    zbf_pid = (-100)
                elif (self.conf_zero_byte_fps and (pid == zbf_pid)):
                    kwargs['device_dirs'] = override_devices
                    self._sleep()
                    zbf_pid = self.fork_child(zero_byte_fps=True, **kwargs)
                    pids.add(zbf_pid)
                else:
                    kwargs['device_dirs'] = [device_list.pop()]
                    pids.add(self.fork_child(**kwargs))
        while pids:
            pid = os.wait()[0]
            if (self.conf_zero_byte_fps and (pid == zbf_pid) and (len(pids) > 1) and (not once)):
                kwargs['device_dirs'] = override_devices
                self._sleep()
                zbf_pid = self.fork_child(zero_byte_fps=True, **kwargs)
                pids.add(zbf_pid)
            pids.discard(pid)
