When we use ./manage.py test ... all is well. Once we add --parallel 8 (as we have quad core machines with HT), we get "connection already closed" errors from psycopg2. This answer seems to suggest that the issue lies in the fact that django creates a connection and then starts branching off from the main thread --> all threads really share the connection. Now if one of them closes the connection, all their connections are closed and the DB starts refusing transactions on that conn.
How do we go ahead and allow testing our codebase without having to mock all DB calls now? Personally, I'd like to mock the DB but (according to project mgmt) it will be an enormous overhead to fix several hundred tests for this.
So: Is there A) a nice drop in DB mock that might keep all records in memory for tests or B) a way to allow several threads to work with psycopg2?
Aucun commentaire:
Enregistrer un commentaire