[Erp5-report] r14179 - /erp5/trunk/utils/oood/pool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 24 02:18:44 CEST 2007


Author: bartek
Date: Tue Apr 24 02:18:42 2007
New Revision: 14179

URL: http://svn.erp5.org?rev=14179&view=rev
Log:
pool size is all workers, busy or not
makeWorkerObject method now checks if OOo loaded, waits longer, tries again, waits a bit and fails only after all this

Modified:
    erp5/trunk/utils/oood/pool.py

Modified: erp5/trunk/utils/oood/pool.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/pool.py?rev=14179&r1=14178&r2=14179&view=diff
==============================================================================
--- erp5/trunk/utils/oood/pool.py (original)
+++ erp5/trunk/utils/oood/pool.py Tue Apr 24 02:18:42 2007
@@ -113,7 +113,7 @@
       return number of existing workers (busy or not)
       so that we can check if the pool is usable at all
     """
-    return len([w for w in self.inst.values() if w and not w.busy])
+    return len([w for w in self.inst.values() if w])
 
   def initializePool(self):
     """
@@ -133,11 +133,48 @@
       make worker object and OOo instance for it (no need to run start.py separately)
       kill OOo if existed
     """
-    self.inst[i] = None
-    start.killInstance(i)
-    start.startInstance(i, keep_control=True)
-    time.sleep(config.instance_load_time)
-    self.inst[i] = (factory.builder.build(self, i))
+    try:
+      self.inst[i] = None
+      # start OOo
+      start.killInstance(i)
+      start.startInstance(i, keep_control=True)
+      time.sleep(config.instance_load_time)
+      try:
+        # build worker
+        self.inst[i] = (factory.builder.build(self, i))
+      except Exception, e:
+        if getattr(e, 'typeName', None) == 'com.sun.star.connection.NoConnectException':
+          # no connection
+          Log.debug('no connection - will retry in %d' % (config.instance_load_time * 2))
+          time.sleep(config.instance_load_time * 2) # let's wait a little longer
+          try:
+            # try to build again
+            self.inst[i] = (factory.builder.build(self, i))
+          except Exception, e:
+            if getattr(e, 'typeName', None) == 'com.sun.star.connection.NoConnectException':
+              # try to kill OOo instance and restart again
+              Log.debug('no connection - restarting OOo')
+              start.killInstance(i)
+              start.startInstance(i, keep_control=True)
+              time.sleep(config.instance_load_time)
+              try:
+                self.inst[i] = (factory.builder.build(self, i))
+              except Exception, e:
+                if getattr(e, 'typeName', None) == 'com.sun.star.connection.NoConnectException':
+                  # no connection
+                  Log.debug('no connection - will retry in %d' % (config.instance_load_time * 2))
+                  time.sleep(config.instance_load_time * 2) # let's wait a little longer
+                  # try for the last time
+                  self.inst[i] = (factory.builder.build(self, i))
+                else:
+                  raise
+            else:
+              raise
+        else:
+          raise
+    except Exception, e:
+      Log.logException(e)
+      raise
 
   def acquire(self):
     """




More information about the Erp5-report mailing list