-
Notifications
You must be signed in to change notification settings - Fork 347
Fix LiveServer
for in-memory SQLite database on Django >= 3.
#947
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
`allow_thread_sharing` is no longer writeable since Django 3.0a1.
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 @icemac, we should definitely fix this. I left a couple of comments.
pytest_django/live_server_helper.py
Outdated
@@ -24,7 +24,10 @@ def __init__(self, addr: str) -> None: | |||
and conn.settings_dict["NAME"] == ":memory:" | |||
): | |||
# Explicitly enable thread-shareability for this connection | |||
conn.allow_thread_sharing = True | |||
try: | |||
conn.inc_thread_sharing() |
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.
We also need to do the corresponding dec_thread_sharing
in stop()
. Django's LiveServerTestCase
does it here: https://github.com/django/django/blob/3ff7f6cf07a722635d690785c31ac89484134bee/django/test/testcases.py#L1578
This is a pre-existing issue -- the previous code neglected set allow_thread_sharing
back as well, but this is a good opportunity to fix it.
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 am not sure id my copy-paste solution is correct, feel free to change my code.
I am not planning to fix the coverage problems. This is too much for a drive-by contribution. |
allow_thread_sharing
is no longer writeable since Django 3.0a1.