[X2go-Commits] python-x2go.git - master (branch) updated: 0.2.0.1-10-g9070692

X2Go dev team git-admin at x2go.org
Thu Jun 7 21:27:58 CEST 2012


The branch, master has been updated
       via  907069213701818b0530242e7d735f6ad88347c2 (commit)
       via  cf525d5c61ed6c238174ab3a5141f72758883766 (commit)
       via  a58f12c5bbe45b817fd0b7a2e7105e3dcf5017c2 (commit)
      from  ab5473d6e4c446309c589f8f5f8413f320e87b7a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 907069213701818b0530242e7d735f6ad88347c2
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Jun 7 21:27:38 2012 +0200

    Do not create a high CPU load after a network failure, do not try to execute a remote command if the session has already died away.

commit cf525d5c61ed6c238174ab3a5141f72758883766
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Jun 7 20:53:51 2012 +0200

    Catch control session deaths when querying X2goSession.is_alive().

commit a58f12c5bbe45b817fd0b7a2e7105e3dcf5017c2
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Jun 7 19:18:18 2012 +0200

    revert a tiny bit of commit 0983bbcce7c7ff1cfd98b9dd96045607fc2a8a1d, that introduced profile disconnections after sessions had been suspended / terminated

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog                 |    3 +++
 x2go/backends/control/_stdout.py |   27 +++++++++++++++++++++------
 x2go/cache.py                    |    5 ++++-
 x2go/session.py                  |   21 ++++++++++++++++++---
 4 files changed, 46 insertions(+), 10 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 8c59458..1f20cfb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ python-x2go (0.2.0.2-0~x2go1) UNRELEASED; urgency=low
     - Add support to X2goSession class to launch sessions for the Python
       command line in five steps.
     - Mark sessions as dead whenever an X2goControlSessionException occurs.
+    - Catch control session deaths when querying X2goSession.is_alive().
+    - Do not create a high CPU load after a network failure, do not try to
+      execute a remote command if the session has already died away.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 30 May 2012 00:27:03 +0200
 
diff --git a/x2go/backends/control/_stdout.py b/x2go/backends/control/_stdout.py
index 2ec995f..05f355c 100644
--- a/x2go/backends/control/_stdout.py
+++ b/x2go/backends/control/_stdout.py
@@ -36,6 +36,7 @@ import random
 import re
 import locale
 import threading
+import cStringIO
 
 from gevent import socket
 
@@ -362,21 +363,26 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient):
         @raise X2goControlSessionException: if the command execution failed (due to a lost connection)
 
         """
-        self._transport_lock.acquire()
-
-        _retval = None
-
         if type(cmd_line) == types.ListType:
             cmd = " ".join(cmd_line)
         else:
             cmd = cmd_line
+
+        if self.session_died:
+            self.logger("control session seams to be dead, not executing command ,,%s'' on X2Go server %s" % (_rerewrite_blanks(cmd), self.profile_name,), loglevel=loglevel)
+            return (cStringIO.StringIO(), cStringIO.StringIO(), cStringIO.StringIO('failed to execute command'))
+
+        self._transport_lock.acquire()
+
+        _retval = None
+
         ssh_transport = self.get_transport()
         if ssh_transport and ssh_transport.is_authenticated():
 
             timer = gevent.Timeout(timeout)
             timer.start()
             try:
-                self.logger("executing command on X2Go server ,,%s'': %s" % (self.profile_name, _rerewrite_blanks(cmd)), loglevel)
+                self.logger("executing command on X2Go server ,,%s'': %s" % (self.profile_name, _rerewrite_blanks(cmd)), loglevel=loglevel)
                 _retval = self.exec_command(_rewrite_password(cmd, user=self.get_transport().get_username(), password=self._session_password), **kwargs)
             except AttributeError:
                 self.session_died = True
@@ -848,7 +854,6 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient):
                     pass
                 except x2go_exceptions.X2goControlSessionException:
                     self.session_died
-                    pass
                 t_obj.__del__()
             for t_name in t_names:
                 try:
@@ -909,6 +914,16 @@ class X2goControlSessionSTDOUT(paramiko.SSHClient):
             self.session_died = True
         return False
 
+    def has_session_died(self):
+        """\
+        Test if the connection to the remote X2Go server died on the way.
+
+        @return: C{True} if the connection has died, C{False} otherwise
+        @rtype: C{bool}
+
+        """
+        return self.session_died
+
     def get_published_applications(self, lang=None, refresh=False, raw=False, very_raw=False, max_no_submenus=defaults.PUBAPP_MAX_NO_SUBMENUS):
         """\
         Retrieve the menu tree of published applications from the remote X2Go server.
diff --git a/x2go/cache.py b/x2go/cache.py
index 6892d8a..5d90191 100644
--- a/x2go/cache.py
+++ b/x2go/cache.py
@@ -82,7 +82,7 @@ class X2goListSessionsCache(object):
 
         """
         while self.protected:
-            gevent.sleep()
+            gevent.sleep(.1)
         try: del self.x2go_listsessions_cache[profile_name]
         except KeyError: pass
 
@@ -155,6 +155,7 @@ class X2goListSessionsCache(object):
         except x2go_exceptions.X2goControlSessionException, e:
             if profile_name in self.x2go_listsessions_cache.keys():
                 del self.x2go_listsessions_cache[profile_name]
+            self.protected = False
             raise e
         except x2go_exceptions.X2goTimeOutException:
             pass
@@ -175,6 +176,7 @@ class X2goListSessionsCache(object):
         except x2go_exceptions.X2goControlSessionException, e:
             if profile_name in self.x2go_listsessions_cache.keys():
                 del self.x2go_listsessions_cache[profile_name]
+            self.protected = False
             raise e
         except x2go_exceptions.X2goTimeOutException:
             pass
@@ -194,6 +196,7 @@ class X2goListSessionsCache(object):
         except x2go_exceptions.X2goControlSessionException, e:
             if profile_name in self.x2go_listsessions_cache.keys():
                 del self.x2go_listsessions_cache[profile_name]
+            self.protected = False
             raise e
 
     def list_sessions(self, session_uuid):
diff --git a/x2go/session.py b/x2go/session.py
index 8fe7b98..9368d96 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -358,6 +358,19 @@ class X2goSession(object):
         """
         return self.client_instance
 
+    def HOOK_on_control_session_death(self):
+        """\
+        HOOK method: called if a control session (server connection) has unexpectedly encountered a failure.
+
+        @param profile_name: profile name of session that called this hook method
+        @type profile_name: C{str}
+
+        """
+        if self.client_instance:
+            self.client_instance.HOOK_on_control_session_death(profile_name=self.profile_name)
+        else:
+            self.logger('HOOK_on_control_session_death: the control session of profile %s has died unexpectedly' % self.profile_name, loglevel=log.loglevel_WARN)
+
     def HOOK_auto_connect(self):
         """\
         HOOK method: called if the session demands to auto connect.
@@ -620,9 +633,6 @@ class X2goSession(object):
         Class destructor.
 
         """
-        if self.is_connected():
-            self.disconnect()
-
         if self.has_control_session() and self.has_terminal_session():
             self.get_control_session().dissociate(self.get_terminal_session())
 
@@ -1243,6 +1253,8 @@ class X2goSession(object):
 
         """
         self.connected = self.control_session.is_alive()
+        if self.control_session.has_session_died():
+            self.HOOK_on_control_session_death()
         if not self.connected:
             self._X2goSession__disconnect()
         return self.connected
@@ -1284,6 +1296,7 @@ class X2goSession(object):
         try:
             return self.control_session.list_sessions(raw=raw)
         except x2go_exceptions.X2goControlSessionException:
+            self.HOOK_on_control_session_death()
             self._X2goSession__disconnect()
             return None
     __list_sessions = list_sessions
@@ -1303,6 +1316,7 @@ class X2goSession(object):
         try:
             return self.control_session.list_desktops(raw=raw)
         except x2go_exceptions.X2goControlSessionException:
+            self.HOOK_on_control_session_death()
             self._X2goSession__disconnect()
             return None
     __list_desktops = list_desktops
@@ -1323,6 +1337,7 @@ class X2goSession(object):
         try:
             return self.control_session.list_mounts(self.session_name, raw=raw)
         except x2go_exceptions.X2goControlSessionException:
+            self.HOOK_on_control_session_death()
             self._X2goSession__disconnect()
             return None
 


hooks/post-receive
-- 
python-x2go.git (Python X2Go Client API)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-x2go.git" (Python X2Go Client API).




More information about the x2go-commits mailing list