-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Docs: improve accuracy of sqlite3 check_same_thread
parameter
#101351
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
Conversation
check_same_thread
description in sqlite3.rstcheck_same_thread
parameter
Looks good to me, committed! |
Any chance to change "serialized" into "sequentialized" here to contrast with serialization as storing state into bytes? |
Interesting observation. Perhaps the wording can be improved there, however I find "sequentialized" a little bit off-kilter (but perhaps that's just me). @CAM-Gerlach? |
@CAM-Gerlach I took your suggestions and believe I have arrived at a simplified solution. Let me know what you think as well as @erlend-aasland . Feel free to modify at will! |
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; the first sentence is a welcome improvement! I believe the second sentence need a little bit more care before we can land this :)
I committed your suggestion @CAM-Gerlach , looks great to me! I think this might require a little more work in order to make clear the initial message I was intending to add: that if SQLite is in serialized mode, Pointing to To be clear in motivation - this issue stems from using Flask with SQLite. Their official guide suggests opening and closing an sqlite3 database connection for each incoming request, which is unnecessarily inefficient if a single (or a pool of) global connection(s) can be safely shared. What makes the global shared connection non trivial is that when attempting it the user will run into the "db connection was accessed from a different thread" error, leading them to believe Flask's suggestion is the only correct approach. Making the docs clearer should help guide those interested in the shared global connection approach towards setting A more drastic step would be to avoid raising the exception altogether if it would be safe to do so, but that would be a bit more complex. And for even more transparency, here is the top-level code I am using to manage this in my
|
Previous information was false: setting `check_same_thread` to `False` does not always require that the user ensure sequentialization themselves, depending on the value of `threadsafety`.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Thanks again, @marcospgp, and thanks for chiming in CAM! I think this is an improvement over the current text. I also agree with CAM that some passages are a little bit vague. We can address those in seperate PRs. |
Thanks @marcospgp for the PR, and @erlend-aasland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-101512 is a backport of this pull request to the 3.11 branch. |
GH-101513 is a backport of this pull request to the 3.10 branch. |
…onGH-101351) (cherry picked from commit ee21110) Co-authored-by: Marcos Pereira <3464445+marcospgp@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
…onGH-101351) (cherry picked from commit ee21110) Co-authored-by: Marcos Pereira <3464445+marcospgp@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Previous information was false: setting
check_same_thread
toFalse
does not always require that the user ensure sequentialization themselves, depending on the value ofthreadsafety
.