The branch, master has been updated via 14bdff2bb22efd16db1561ee229e8ae004396a21 (commit) via 20679137ce0388c27829cd4948afd33414abe494 (commit) from da000f3c040a8217ebdfc10e6d25065a1b887810 (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 14bdff2bb22efd16db1561ee229e8ae004396a21 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Nov 17 00:24:53 2012 +0100 use non-locking _suspend method for transferring sessions from one client to another commit 20679137ce0388c27829cd4948afd33414abe494 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Nov 17 00:23:25 2012 +0100 try a more intelligent approach for method locking ----------------------------------------------------------------------- Summary of changes: x2go/session.py | 120 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 102 insertions(+), 18 deletions(-) The diff of changes is: diff --git a/x2go/session.py b/x2go/session.py index 678b222..91d74a7 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -1703,7 +1703,36 @@ class X2goSession(object): """ self._lock.acquire() + try: + _retval = self._resume(session_name=session_name, session_list=session_list, cmd=cmd, progress_event=progress_event) + except: + raise + finally: + self._lock.release() + return _retval + + def _resume(self, session_name=None, session_list=None, cmd=None, progress_event=None): + """\ + Resume or continue a suspended / running X2Go session on the + remote X2Go server. + + @param session_name: the server-side name of an X2Go session + @type session_name: C{str} + @param session_list: a session list to avoid a server-side session list query + @type session_list: C{dict} + @param cmd: if starting a new session, manually hand over the command to be launched in + the new session + @type cmd: C{str} + @param progress_event: a C{thread.Event} object that notifies a status object like the one in + L{utils.ProgressStatus}. + @type progress_event: C{obj} + + @return: returns C{True} if resuming the session has been successful, C{False} otherwise + @rtype: C{bool} + @raise Exception: any exception that occurs during published application menu retrieval is passed through + + """ # initialize a dummy event to avoid many if clauses further down in the code self.reset_progress_status() _dummy_event = threading.Event() @@ -1738,9 +1767,7 @@ class X2goSession(object): if self.is_running(): try: - self._lock.release() - self.suspend() - self._lock.acquire() + self._suspend() self._progress_status = 10 progress_event.set() @@ -1764,7 +1791,6 @@ class X2goSession(object): self._progress_status = -1 progress_event.set() - self._lock.release() raise if cmd is not None: @@ -1789,7 +1815,6 @@ class X2goSession(object): self._progress_status = -1 progress_event.set() - self._lock.release() return False self._progress_status = 30 @@ -1875,7 +1900,6 @@ class X2goSession(object): progress_event.set() self.has_terminal_session() and self.terminal_session.session_info_unprotect() - self._lock.release() return True else: @@ -1884,7 +1908,6 @@ class X2goSession(object): self._progress_status = -1 progress_event.set() - self._lock.release() return False else: @@ -1893,7 +1916,6 @@ class X2goSession(object): progress_event.set() self._X2goSession__disconnect() - self._lock.release() return False __resume = resume @@ -1946,7 +1968,43 @@ class X2goSession(object): """ self._lock.acquire() + try: + _retval = self._share_desktop(desktop=desktop, user=user, display=display, share_mode=share_mode, check_desktop_list=check_desktop_list, progress_event=progress_event) + except: + raise + finally: + self._lock.release() + return _retval + + def _share_desktop(self, desktop=None, user=None, display=None, share_mode=0, check_desktop_list=True, progress_event=None): + """\ + Share an already running X2Go session on the remote X2Go server locally. The shared session may be either + owned by the same user or by a user that grants access to his/her desktop session by the local user. + + @param desktop: desktop ID of a sharable desktop in format <user>@<display> + @type desktop: C{str} + @param user: user name and display number can be given separately, here give the + name of the user who wants to share a session with you. + @type user: C{str} + @param display: user name and display number can be given separately, here give the + number of the display that a user allows you to be shared with. + @type display: C{str} + @param share_mode: desktop sharing mode, 0 is VIEW-ONLY, 1 is FULL-ACCESS. + @type share_mode: C{int} + @param check_desktop_list: check if the given desktop is available on the X2Go server; handle with care as + the server-side C{x2golistdesktops} command might block client I/O. + @type check_desktop_list: C{bool} + @param progress_event: a C{thread.Event} object that notifies a status object like the one in + L{utils.ProgressStatus}. + @type progress_event: C{obj} + + @return: returns C{True} if starting the session has been successful, C{False} otherwise + @rtype: C{bool} + @raise X2goDesktopSharingException: if the given desktop ID is not an available desktop session on the remote server + @raise X2goSessionException: if the available desktop session appears to be dead, in fact + + """ # initialize a dummy event to avoid many if clauses further down in the code self.reset_progress_status() _dummy_event = threading.Event() @@ -2015,7 +2073,6 @@ class X2goSession(object): self._progress_status = 100 progress_event.set() - self._lock.release() return self.running else: self.terminal_session = None @@ -2030,7 +2087,6 @@ class X2goSession(object): self._X2goSession__disconnect() - self._lock.release() return False __share_desktop = share_desktop @@ -2045,6 +2101,24 @@ class X2goSession(object): """ self._lock.acquire() + try: + _retval = self._suspend() + except: + raise + finally: + self._lock.release() + return _retval + + def _suspend(self): + """\ + Suspend this X2Go session. + + @return: returns C{True} if suspending the session has been successful, C{False} otherwise + @rtype: C{bool} + + @raise X2goSessionException: if the session could not be suspended + + """ if self.is_alive(): if self.has_terminal_session(): @@ -2064,7 +2138,6 @@ class X2goSession(object): self.session_cleanup() del self.terminal_session self.terminal_session = None - self._lock.release() return True elif self.has_control_session() and self.session_name: @@ -2076,17 +2149,14 @@ class X2goSession(object): self.faulty = False self.active = False self.session_cleanup() - self._lock.release() return True else: - self._lock.release() raise x2go_exceptions.X2goSessionException('cannot suspend session') else: self._X2goSession__disconnect() - self._lock.release() return False __suspend = suspend @@ -2101,6 +2171,24 @@ class X2goSession(object): """ self._lock.acquire() + try: + _retval = self._terminate() + except: + raise + finally: + self._lock.release() + return _retval + + def _terminate(self): + """\ + Terminate this X2Go session. + + @return: returns C{True} if terminating the session has been successful, C{False} otherwise + @rtype: C{bool} + + @raise X2goSessionException: if the session could not be terminated + + """ if self.is_alive(): if self.has_terminal_session(): @@ -2119,7 +2207,6 @@ class X2goSession(object): self.session_cleanup() del self.terminal_session self.terminal_session = None - self._lock.release() return True elif self.has_control_session() and self.session_name: @@ -2131,16 +2218,13 @@ class X2goSession(object): self.faulty = False self.active = False self.session_cleanup() - self._lock.release() return True else: - self._lock.release() raise x2go_exceptions.X2goSessionException('cannot terminate session') else: self._X2goSession__disconnect() - self._lock.release() return False __terminate = terminate 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).