[Zope-dev] Bug w/patch: error in requestprofiler.py meaning it misses a lot of records

Dyon Balding dyon.balding@monster.com
Tue, 21 Aug 2001 10:48:04 -0700


I just submitted this:

http://classic.zope.org:8080/Collector/2536/view

Description:
requestprofiler.py was using the id of the request
to index it in the finished dictionary. the id is only
guaranteed to be unique for the lifetime of the
request, and therefore the same id appears many
times in a long log file.

in one instance, requestprofiler was only finding
57 hits in a file that actually had close to 4000.

this patch changes finished to be a list - it doesn't
need to be a dictionary, and solves the problem.

Patch:

--- /home/dyon/work/ht/zope/Zope-2.4.0/utilities/requestprofiler.py     Thu May 17 08:53:43 2001
+++ requestprofiler.py  Tue Aug 21 10:10:37 2001
@@ -293,7 +293,7 @@
 def analyze(f, top, sortf, start=None, end=None, mode='cumulative'):
     beginrequests = {}
     cumulative = {}
-    finished = {}
+    finished = []
     unfinished = {}
     
     while 1:
@@ -318,11 +318,10 @@
         request.put(code, int(fromepoch), desc)
         if request.isfinished():
             del unfinished[id]
-            finished[id] = request
+            finished.append(request)
             request.active = len(unfinished)
             
-    finished.update(unfinished)
-    requests = finished.values()
+    requests = finished + unfinished.values()
 
     if mode == 'cumulative':
         for request in requests:

-- 
| Dyon Balding . Software Engineer . HiringTools.Monster.com
|   dyon@hiringtools.com . +1 415 288 3375