<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _build(self, items, chunk_size=10000):
 """Build the output, in chunks. :return: Number of items processed :rtype: int """

        _log.debug("_build, chunk_size={:d}".format(chunk_size))
        n, i = 0, 0
        for i, item in enumerate(items):
            if i == 0:
                _log.debug("_build, first item")
            if 0 == (i + 1) % chunk_size:
                if self._seq:
                    self._run(0)
                else:
                    self._run_parallel_fn()  # process the chunk
                if self._status.has_failures():
                    break
                n = i + 1
            self._queue.put(item)
        # process final chunk
        if self._seq:
            self._run(0)
        else:
            self._run_parallel_fn()
        if not self._status.has_failures():
            n = i + 1
        return n