Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #222 from napalm-automation/add-del
Browse files Browse the repository at this point in the history
Add __del__ to close on exit
  • Loading branch information
mirceaulinic authored Mar 17, 2017
2 parents ee512bb + 842a801 commit 8d4509a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
if exc_type is not None:
self.__raise_clean_exception(exc_type, exc_value, exc_traceback)

def __del__(self):
"""
This method is used to cleanup when the program is terminated suddenly.
We need to make sure the connection is closed properly and the configuration DB
is released (unlocked).
"""
self.close()

@staticmethod
def __raise_clean_exception(exc_type, exc_value, exc_traceback):
"""
Expand Down

0 comments on commit 8d4509a

Please sign in to comment.