[mirrorbrain-commits] [mod_stats] r57 - /trunk/tools/dlcount.py

From: <poeml_at_mirrorbrain.org>
Date: Tue, 15 Dec 2009 01:26:08 -0000
Author: poeml
Date: Tue Dec 15 02:26:07 2009
New Revision: 57

URL: http://svn.mirrorbrain.org/viewvc/mod_stats?rev=57&view=rev
Log:
Django accumulates memory when running in Debug mode.
Install a cleanup handler.

Modified:
    trunk/tools/dlcount.py

Modified: trunk/tools/dlcount.py
URL: http://svn.mirrorbrain.org/viewvc/mod_stats/trunk/tools/dlcount.py?rev=57&r1=56&r2=57&view=diff
==============================================================================
--- trunk/tools/dlcount.py (original)
+++ trunk/tools/dlcount.py Tue Dec 15 02:26:07 2009
@@ -384,12 +384,21 @@
         os.environ['DJANGO_SETTINGS_MODULE'] = 'downloadstats.settings'
         from downloadstats.stats.models import Counter
 
-        #counters = Counter.objects.all()
-        #for i in counters:
-        #    print i
+        import downloadstats.settings 
+        if downloadstats.settings.DEBUG:
+            from django import db
+            #print 'you are runninng in DEBUG mode. This is not recommended,\n' \
+            #      'because Django then saves a copy of every SQL statement it has\n' \
+            #      'executed. Installing a cleanup handler.'
+            # see below
+            # http://docs.djangoproject.com/en/dev/faq/models/#why-is-django-leaking-memory
 
     for item in items:
         if item.countable:
+
+            if downloadstats.settings.DEBUG:
+                db.reset_queries()
+
             #print item.country, item.url
             (product, osname, version, lang) = item.url.split()
 




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Tue Dec 15 2009 - 01:26:10 GMT

This archive was generated by hypermail 2.2.0 : Tue Dec 15 2009 - 15:20:04 GMT