#12118: in-memory test database does not work with threads
-------------------------------------+-------------------------------------
Reporter: bluebird75 | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.1
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: threads | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anonymous):
* status: closed => new
* severity: => Normal
* type: => Uncategorized
* easy: => 0
* ui_ux: => 0
* resolution: invalid =>
Comment:
I vote to reopen this.
sqlite, as of version 3.7.13 (released 2012-06-11) has the ability to
share an in-memory database between multiple connections and threads.
See: http://www.sqlite.org/releaselog/3_7_13.html
Making this work with the Django testing framework should be pretty easy:
In the sqlite database backend, instead of using the database name
`:memory:`, we should use a name such as
`file:testdb?mode=memory&cache=shared` (where "testdb" can be anything and
ideally should be unique so that multiple tests can run concurrently, each
with its own individual database).
As a bonus, doing this should allow removing the hacky sqlite-specific
code from "LiveServerTestCase" (It contains a messy workaround for exactly
the issue of this bug report)
The only thing that might be a little tricky is making this update in the
Django code to still support older vesions of sqlite by falling back to
the current behavior (`:memory:`), but I imagine that this shouldn't be
too difficult.
--
Ticket URL: <https://code.djangoproject.com/ticket/12118#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.1c052d2ddf4c9480e2dca17a0e9d1330%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.