class_docstr: This thread takes care of writing history to the database, so that
  the UI isn't held up while that happens.
  
  It waits for the HistoryManager's save_flag to be set, then writes out
  the history cache. The main thread is responsible for setting the flag when
  the cache size reaches a defined threshold.
class_docstr_tok: ["This","thread","takes","care","of","writing","history","to","the","database",",","so","that","the","UI","is","n't","held","up","while","that","happens",".","It","waits","for","the","HistoryManager","'s","save_flag","to","be","set",",","then","writes","out","the","history","cache",".","The","main","thread","is","responsible","for","setting","the","flag","when","the","cache","size","reaches","a","defined","threshold","."]
docstr: This can be called from the main thread to safely stop this thread.
  
  Note that it does not attempt to write out remaining history before
  exiting. That should be done by calling the HistoryManager's
  end_session method.
docstr_tok: ["This","can","be","called","from","the","main","thread","to","safely","stop","this","thread",".","Note","that","it","does","not","attempt","to","write","out","remaining","history","before","exiting",".","That","should","be","done","by","calling","the","HistoryManager's","end_session","method","."]
code: def stop(self):
      """This can be called from the main thread to safely stop this thread.
  
      Note that it does not attempt to write out remaining history before
      exiting. That should be done by calling the HistoryManager's
      end_session method."""
      self.stop_now = True
      self.history_manager.save_flag.set()
      self.join()
  
imports: from __future__ import print_function
  import atexit
  import datetime
  import os
  import re
  import threading
  from traitlets.config.configurable import LoggingConfigurable
  from decorator import decorator
  from IPython.utils.decorators import undoc
  from IPython.paths import locate_profile
  from IPython.utils import py3compat
  from traitlets import Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError, default, observe
  from warnings import warn
label_desc: Use image node_id 3 for calling the HistorySavingThread obj's underlying member method code with example usage: obj.stop() without return types