aosabook/500lines · error · ValueError
Database closed.
Error message
Database closed.
What it means
Error "Database closed." thrown in aosabook/500lines.
Source
Thrown at data-store/code/dbdb/interface.py:13
from dbdb.binary_tree import BinaryTree
from dbdb.physical import Storage
class DBDB(object):
def __init__(self, f):
self._storage = Storage(f)
self._tree = BinaryTree(self._storage)
def _assert_not_closed(self):
if self._storage.closed:
raise ValueError('Database closed.')
def close(self):
self._storage.close()
def commit(self):
self._assert_not_closed()
self._tree.commit()
def __getitem__(self, key):
self._assert_not_closed()
return self._tree.get(key)
def __setitem__(self, key, value):
self._assert_not_closed()
return self._tree.set(key, value)
def __delitem__(self, key):
self._assert_not_closed()View on GitHub (pinned to fba689d101)
Solutions
- Do not call get/set/commit/delete after calling db.close().
- Reopen the database with dbdb.connect(path) to continue using it.
- Use a context manager (with dbdb.connect(...) as db) so close happens after all operations.
Example fix
db = dbdb.connect('data.db'); db.commit(); db.close(); db = dbdb.connect('data.db') # reopen instead of using the closed handle When it happens
Trigger: Thrown at data-store/code/dbdb/interface.py:13 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of aosabook/500lines@fba689d101 (2026-08-13).
Data as JSON: /api/errors/65f186c32f2f2198.
Report an issue: GitHub.