1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #3711, #6734, #12581 -- Bounded connection.queries.

Prevented unlimited memory consumption when running background tasks
with DEBUG=True.

Thanks Rob, Alex, Baptiste, and others.
This commit is contained in:
Aymeric Augustin
2014-06-07 14:09:27 +02:00
parent e2112edd9a
commit cfcca7ccce
8 changed files with 94 additions and 33 deletions

View File

@@ -91,7 +91,7 @@ class BulkCreateTests(TestCase):
def test_large_batch(self):
with override_settings(DEBUG=True):
connection.queries = []
connection.queries_log.clear()
TwoFields.objects.bulk_create([
TwoFields(f1=i, f2=i + 1) for i in range(0, 1001)
])
@@ -112,7 +112,7 @@ class BulkCreateTests(TestCase):
@skipUnlessDBFeature('has_bulk_insert')
def test_large_batch_efficiency(self):
with override_settings(DEBUG=True):
connection.queries = []
connection.queries_log.clear()
TwoFields.objects.bulk_create([
TwoFields(f1=i, f2=i + 1) for i in range(0, 1001)
])
@@ -124,7 +124,7 @@ class BulkCreateTests(TestCase):
mixed together with objects without PK set.
"""
with override_settings(DEBUG=True):
connection.queries = []
connection.queries_log.clear()
TwoFields.objects.bulk_create([
TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i + 1)
for i in range(100000, 101000)])
@@ -142,7 +142,7 @@ class BulkCreateTests(TestCase):
mixed together with objects without PK set.
"""
with override_settings(DEBUG=True):
connection.queries = []
connection.queries_log.clear()
TwoFields.objects.bulk_create([
TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i + 1)
for i in range(100000, 101000)])