'Context manager used to speedup insertion of big number of records
>>> d1 = DbDict(\'test\')
>>> with d1.bulk_commit():
...     for i in range(1000):
...         d1[i] = i * 2'

@contextmanager
def bulk_commit(self):

    self._bulk_commit = True
    self.can_commit = False
    try:
        (yield)
        self.commit(True)
    finally:
        self._bulk_commit = False
        self.can_commit = True
        self._pending_connection.close()
        self._pending_connection = None
