piskvorky / sqlitedict

Persistent dict, backed by sqlite3 and pickle, multithread-safe.
Apache License 2.0
1.17k stars 131 forks source link

Fix exit errors: TypeError("'NoneType' object is not callable",) #44

Closed piskvorky closed 8 years ago

piskvorky commented 8 years ago

When a Python process exits that has some sqlitedict objects still in memory, the final pre-exit garbage collection can cause some unsightly errors being printed:

Exception TypeError: TypeError("'NoneType' object is not callable",) in <bound method SqliteDict.__del_ of SqliteDict(/data/db.sqlite)> ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in ignored

Investigate why this happens (there are already checks in place inside __del__) and fix it.

Desired behaviour: if the sqlite connection is still open/active, close it; if not, or if any error happens (object already partially self-destructed by exit, or any other error.. we have little control over what we can do at this point), just ignore it and proceed.

tmylk commented 8 years ago

Fixed in #45