server/repository.py
branchstable
changeset 8953 041804bc48e9
parent 8890 57ffd0e0643d
child 8954 9d30719142bf
--- a/server/repository.py	Fri Apr 26 18:21:18 2013 +0200
+++ b/server/repository.py	Tue Apr 16 16:51:18 2013 +0200
@@ -1635,8 +1635,22 @@
         # into the pyro name server
         if self._use_pyrons():
             self.looping_task(60*10, self._ensure_pyro_ns)
+        # install hacky function to free cnxset
+        self.looping_task(60, self._cleanup_pyro)
         return daemon
 
+    def _cleanup_pyro(self):
+        """Very hacky function to cleanup session left by dead Pyro thread.
+
+        There is no clean pyro callback to detect this.
+        """
+        for session in self._sessions.values():
+            for thread, cnxset in session._threads_in_transaction.copy():
+                if not thread.isAlive():
+                    self.warning('Freeing cnxset used by dead pyro threads: %',
+                                 thread)
+                    session._free_thread_cnxset(thread, cnxset)
+
     def _ensure_pyro_ns(self):
         if not self._use_pyrons():
             return