Create a new history manager associated with a shell instance.
(self, shell=None, config=None, **traits)
| 530 | _exit_re = re.compile(r"(exit|quit)(\s*\(.*\))?$") |
| 531 | |
| 532 | def __init__(self, shell=None, config=None, **traits): |
| 533 | """Create a new history manager associated with a shell instance. |
| 534 | """ |
| 535 | # We need a pointer back to the shell for various tasks. |
| 536 | super(HistoryManager, self).__init__(shell=shell, config=config, |
| 537 | **traits) |
| 538 | self.save_flag = threading.Event() |
| 539 | self.db_input_cache_lock = threading.Lock() |
| 540 | self.db_output_cache_lock = threading.Lock() |
| 541 | |
| 542 | try: |
| 543 | self.new_session() |
| 544 | except OperationalError: |
| 545 | self.log.error("Failed to create history session in %s. History will not be saved.", |
| 546 | self.hist_file, exc_info=True) |
| 547 | self.hist_file = ':memory:' |
| 548 | |
| 549 | if self.enabled and self.hist_file != ':memory:': |
| 550 | self.save_thread = HistorySavingThread(self) |
| 551 | self.save_thread.start() |
| 552 | |
| 553 | def _get_hist_file_name(self, profile=None): |
| 554 | """Get default history file name based on the Shell's profile. |
no test coverage detected