'Create a new history manager associated with a shell instance.'

def __init__(self, shell=None, config=None, **traits):

    super(HistoryManager, self).__init__(shell=shell, config=config, **traits)
    self.save_flag = threading.Event()
    self.db_input_cache_lock = threading.Lock()
    self.db_output_cache_lock = threading.Lock()
    try:
        self.new_session()
    except OperationalError:
        self.log.error('Failed    to    create    history    session    in    %s.    History    will    not    be    saved.', self.hist_file, exc_info=True)
        self.hist_file = ':memory:'
    if (self.enabled and (self.hist_file != ':memory:')):
        self.save_thread = HistorySavingThread(self)
        self.save_thread.start()
