-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Conversation
There was a problem hiding this 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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Line 3 in 85ca9ad
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".
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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:
- SQLite requires journal_mode to be
WAL
for concurrently reading and writing journal_mode=OFF
only applies to the current connection, so only the connection creating tables are running withjournal_mode=OFF
. Starting ehforwarderbot with existing db will use the default journal_mode.
SqliteQueueDatabase requires journal_mode to be WAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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
Fix #6
See: