piskvorky / sqlitedict

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

Wrapper object using a destructor appears to hang on closing the sqlitedict #95

Open CMCDragonkai opened 5 years ago

CMCDragonkai commented 5 years ago

I have found that wrapping sqlitedict in an class with a destructor doesn't seem to work.

Here's just a snippet of my code:

from sqlitedict import SqliteDict

class Store():

    def __init__(self, path):
        self._map = SqliteDict(path, autocommit=False)

    def __del__(self):
        self._map.close()

store = Store('tmp/ext')

Run this with python ./script.py. And it just hangs.

Instead I have to use close(force=True) for it actually properly close.