Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a corrupted database does not raise exception gracefully #129

Open
mtanti opened this issue Jan 9, 2021 · 2 comments
Open

Loading a corrupted database does not raise exception gracefully #129

mtanti opened this issue Jan 9, 2021 · 2 comments
Labels
bug help-needed PRs for this issue are most welcome

Comments

@mtanti
Copy link

mtanti commented Jan 9, 2021

If you try to load a file which isn't a database, you get the following error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "...\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "...\lib\site-packages\sqlitedict.py", line 396, in run
    conn.execute('PRAGMA journal_mode = %s' % self.journal_mode)
sqlite3.DatabaseError: file is not a database

The problem here is that the error raises in a thread which then dies and leave your console hanging, probably due to missing multithread error handling.

I find it strange that I should get multithreading when I use SqliteDict and not SqliteMultithread, which I traced to the _new_conn method. A quick fix would be to avoid using multithreading when none is requested in order to avoid this sort of error when not using multithreading at least.

@piskvorky piskvorky added the bug label Jan 9, 2021
@piskvorky
Copy link
Owner

Thanks for reporting @mtanti . Will you be able to look into this, submit a PR?

@mtanti
Copy link
Author

mtanti commented Jan 10, 2021

Thanks for reporting @mtanti . Will you be able to look into this, submit a PR?

No I don't have time, sorry.

@mpenkov mpenkov added the help-needed PRs for this issue are most welcome label Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-needed PRs for this issue are most welcome
Projects
None yet
Development

No branches or pull requests

3 participants