Browse Source

Be more careful closing history DB

Fixes #485
patch-2
Neil Booth 7 years ago
parent
commit
69754a62eb
  1. 5
      server/history.py

5
server/history.py

@ -30,6 +30,7 @@ class History(object):
self.max_hist_row_entries = 12500 self.max_hist_row_entries = 12500
self.unflushed = defaultdict(partial(array.array, 'I')) self.unflushed = defaultdict(partial(array.array, 'I'))
self.unflushed_count = 0 self.unflushed_count = 0
self.db = None
def open_db(self, db_class, for_sync, utxo_flush_count): def open_db(self, db_class, for_sync, utxo_flush_count):
self.db = db_class('hist', for_sync) self.db = db_class('hist', for_sync)
@ -38,7 +39,9 @@ class History(object):
return self.flush_count return self.flush_count
def close_db(self): def close_db(self):
self.db.close() if self.db:
self.db.close()
self.db = None
def read_state(self): def read_state(self):
state = self.db.get(b'state\0\0') state = self.db.get(b'state\0\0')

Loading…
Cancel
Save