patx / pickledb

pickleDB is an open source key-value store using Python's json module.
https://patx.github.io/pickledb
BSD 3-Clause "New" or "Revised" License
925 stars 125 forks source link

fix open file handle if pickledb.load fails #29

Open ThPoll opened 7 years ago

ThPoll commented 7 years ago

Hi patx,

I had problems with my client when the json file was corrupt. E.g. you simple add additional chars behind the closing curly bracket. }sadfasdf

In this case pickledb raises an exception, but the file handle remains open. I wanted to delete this file, but this was not possible due to open handle. My proposal solves this issue. Hope you like it...

Thank you, Thomas