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

fix: fix "Database is locked" #110

Merged
merged 3 commits into from Aug 15, 2021
Merged

fix: fix "Database is locked" #110

merged 3 commits into from Aug 15, 2021

Conversation

Copy link
Member

@blueset blueset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. I’ve left a comment inline.

setup.py Outdated
@@ -15,8 +15,8 @@
long_description = open('README.rst').read()

tests_require = ["pytest", "telethon", "cryptg", "pytest-dotenv", "flaky",
"pytest-asyncio", "mypy", "pytest-html", "doit", "PySocks",
"coverage", "sphinx"]
"pytest-asyncio", "mypy==0.910", "pytest-html", "doit", "PySocks",
Copy link
Member

@blueset blueset Aug 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share the reason for these dependency changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy used to bundle stubs for 3rd party libraries, but since mypy 0.900 they don't include these stubs anymore. So we need to add types-setuptools as test dependencies or mypy will complain about missing stubs in

from setuptools import setup, find_packages
.

I also pinned mypy to the latest version, since mypy is not stable and may make more breaking changes in the future, and not pinning version might cause more "surprises".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I think it would be better to set the version limit to >= instead of a strict ==. In recent years I’ve been relying on the CI tests on GitHub Actions to follow up with the latest updates of Mypy. Since it is a test dependency, there is no much impact on the end users when type check breaks on Mypy updates. (For the same reason I locked in Python Telegram Bot version for stability.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the version limit to >=.

I also removed PRAGMA journal_mode = OFF when creating tables, since:

  1. SQLite requires journal_mode to be WAL for concurrently reading and writing
  2. journal_mode=OFF only applies to the current connection, so only the connection creating tables are running with journal_mode=OFF. Starting ehforwarderbot with existing db will use the default journal_mode.

Copy link
Member

@blueset blueset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@blueset blueset merged commit 7ecc45e into ehForwarderBot:master Aug 15, 2021
YouXam pushed a commit to YouXam/efb-telegram-master that referenced this pull request Apr 13, 2023
* fix: use SqliteQueueDatabase

See: https://www.reddit.com/r/learnpython/comments/ab0z3n/sqlite_database_locked_how_to_use_sqlite_with/

Fixes ehForwarderBot#6

* fix: add types-setuptools as tests_require

* fix: don't set journal_mode to OFF when creating table

SqliteQueueDatabase requires journal_mode to be WAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database is locked
2 participants