Right I think this was fixed in r13170 while fixing a python 2.4
incompatibility bug.

try attached patch please.

you can get the java version of lucene from the jar file name, on my
system the file is /usr/share/java/lucene-2.4.0.jar

cheers,
Alaa

 On Fri, 08 Jan 2010 15:03:05 +0100
Johannes Ahlers <johannes.ahl...@futura4retail.com> wrote:

> Hi Alaa,
> > I need more info to figure this out, attached is a patch will will
> > display a full traceback instead of just the warning, please apply
> > it, switch back to Xapian (you'll need to delete the lucene index
> > directories) and run refresh_stats again.
> >   
> I applied the path (but changed the print-command to a 
> logging.warning-call). Enclosed you can find the log-file. I reset
> the values for  TranslationStoreFieldFile._store_cache.maxsize  and 
> TranslationStoreFieldFile._store_cache.cullsize in refresh_stats.py
> back to 2/2. I tried other combinations (8/2, 8/8, 10/10, 40/10) but
> this had no effects to the error-logging. But it effects how many
> xliff-files will be refreshed in stats.db when recomputing the files.
> With 2/2 about 16 of 22 files per directory couldn't be read. I got
> the read exclamation marks with the corresponding message. Currently
> I'm using 40/10 and now the exclamations marks disappeared completely.
> > as for the pylucene problem, it is probably related to version
> > (being a pain to install and not commonly packaged PyLucene doesn't
> > get much testing outside my machine). do you know what version of
> > lucene you are using (I'll need both the python api and the java
> > lucene version). 
> I used PyLucene 2.3.1 because it is included in the ubuntu
> repository. This was installed under python2.5, so I created a
> symlink for python2.6. I think it is properly installed. In Python2.6
> console I can execute "import lucene" and
> "lucene.initVM(lucene.CLASSPATH) ==> <jcc.JCCEnv object at
> 0x7f8692fb30d8>" without errors. How can I retrieve the
> 0x7f8692fb30d8>java-lucene-version?
> 
> I although tried to install the current PyLucene release 3.0.0 but I 
> failed because of the complicated build/installation procedure...
> 
> Greets
> 
> Johannes
--- src/trunk/translate/misc/lru.py	2009-11-17 15:12:48 UTC (rev 13169)
+++ src/trunk/translate/misc/lru.py	2009-11-17 15:14:47 UTC (rev 13170)
@@ -48,20 +48,38 @@
             # appended again
             self.queue.pop()
 
+        if len(self) >= self.maxsize:
+            # maximum cache size exceeded, cull old items
+            #
+            # note queue is the real cache but its size is boundless
+            # since it might have duplicate references.
+            #
+            # don't bother culling if queue is smaller than weakref,
+            # this means there are too many references outside the
+            # cache, culling won't free much memory (if any).
+            while len(self) >= self.maxsize <= len(self.queue):
+                cullsize = max(int(len(self.queue) / self.cullsize), 2)
+                try:
+                    for i in range(cullsize):
+                        self.queue.popleft()                        
+                except IndexError:
+                    # queue is empty, bail out.
+                    break
+                finally:
+                    # call garbage collecter manually since objects
+                    # with circular references take some time to get
+                    # collected
+                    for i in range(5):
+                        if gc.collect() == 0:
+                            break
         self.queue.append((key, value))
         WeakValueDictionary.__setitem__(self, key, value)
 
-        if len(self) > self.maxsize:
-            while len(self.queue) and len(self) > (self.maxsize - self.maxsize / self.cullsize):
-                # maximum cache size exceeded, remove an old item
-                self.queue.popleft()
-                while gc.collect() > 0:
-                    pass
-
+    
     def __getitem__(self, key):
         value = WeakValueDictionary.__getitem__(self, key)
         # check boundaries to minimiza duplicate references
-        while len(self.queue) > 1 and self.queue[0][0] == key:
+        while len(self.queue) > 0  and self.queue[0][0] == key:
             # item at left end of queue pop it since it'll be appended
             # to right
             self.queue.popleft()
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle

Reply via email to