Jeremy Self committed e797c60

Fix for test running into race condition

  • Participants
  • Parent commits 90dafaa

Comments (0)

Files changed (1)


 import django
 from django.conf import settings
 from django.db import connection
+    from django.db import connections
+    connections = None
 from johnny import middleware
 from johnny import settings as johnny_settings
 import base
             obj = eval(_query)
+            if connections is not None:
+                #this is to fix a race condition with the
+                #thread to ensure that we close it before 
+                #the next test runs
+                connections['default'].close()
         t = Thread(target=_inner, args=(query,))
         Similar to the commit, this sets up a write to a db in a transaction,
         reads from it (to force a cache write of sometime), then rolls back."""
         from Queue import Queue as queue
         from django.db import transaction
         from testapp.models import Genre, Publisher