code: def _commit(self, mergetype, optimize, merge):
      # Index the remaining documents in the doc buffer
      if self.docbuffer:
          self._enqueue()
      # Tell the tasks to finish
      for task in self.tasks:
          self.jobqueue.put(None)
  
      # Merge existing segments
      finalsegments = self._merge_segments(mergetype, optimize, merge)
  
      # Wait for the subtasks to finish
      for task in self.tasks:
          task.join()
  
      # Pull a (run_file_name, fieldnames, segment) tuple off the result
      # queue for each sub-task, representing the final results of the task
      results = []
      for _ in self.tasks:
          try:
              results.append(self.resultqueue.get(timeout=1))
          except queue.Empty:
              pass
  
      if self.multisegment:
          # If we're not merging the segments, we don't care about the runname
          # and fieldnames in the results... just pull out the segments and
          # add them to the list of final segments
          finalsegments += [s for _, _, s in results]
          if self._added:
              finalsegments.append(self._finalize_segment())
          else:
              self._close_segment()
          assert self.perdocwriter.is_closed
      else:
          # Merge the posting sources from the sub-writers and my
          # postings into this writer
          self._merge_subsegments(results, mergetype)
          self._close_segment()
          self._assemble_segment()
          finalsegments.append(self.get_segment())
          assert self.perdocwriter.is_closed
  
      self._commit_toc(finalsegments)
      self._finish()
  
imports: from __future__ import with_statement
  from multiprocessing import Process, Queue, cpu_count
  from whoosh.compat import queue, xrange, pickle
  from whoosh.codec import base
  from whoosh.writing import SegmentWriter
  from whoosh.externalsort import imerge
  from whoosh.util import random_name
label_desc: Use image node_id 10 for calling the MpWriter obj's underlying member method code with example usage: obj._commit(mergetype, optimize, merge) without return types