diff options
author | kali <kali@leap.se> | 2013-06-15 01:28:59 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-06-15 01:31:11 +0900 |
commit | e6a181c13e8bf99a893b3e3881c13d2df23701a7 (patch) | |
tree | aced8cb3ba7b9d6db54740fbaf327144008b22b9 /src/leap/crypto/srpauth.py | |
parent | 561e7bc90f21efe5f86be7a842c283f4b7fa7610 (diff) | |
parent | 8bee5f4e9a1bb0f7069fe41ab37dfec000487d7b (diff) |
Merge remote-tracking branch 'chiiph/bug/true_threading' into develop
Closes #2848
Diffstat (limited to 'src/leap/crypto/srpauth.py')
-rw-r--r-- | src/leap/crypto/srpauth.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/leap/crypto/srpauth.py b/src/leap/crypto/srpauth.py index bcd24de3..0e95ae64 100644 --- a/src/leap/crypto/srpauth.py +++ b/src/leap/crypto/srpauth.py @@ -24,6 +24,7 @@ import json #this error is raised from requests from simplejson.decoder import JSONDecodeError +from functools import partial from PySide import QtCore from twisted.internet import threads @@ -321,6 +322,9 @@ class SRPAuth(QtCore.QObject): self.set_session_id(session_id) + def _threader(self, cb, res, *args, **kwargs): + return threads.deferToThread(cb, res, *args, **kwargs) + def authenticate(self, username, password): """ Executes the whole authentication process for a user @@ -341,10 +345,17 @@ class SRPAuth(QtCore.QObject): username=username, password=password) - d.addCallback(self._start_authentication, username=username, - password=password) - d.addCallback(self._process_challenge, username=username) - d.addCallback(self._verify_session) + d.addCallback( + partial(self._threader, + self._start_authentication), + username=username, + password=password) + d.addCallback( + partial(self._threader, + self._process_challenge), + username=username) + d.addCallback(partial(self._threader, + self._verify_session)) return d @@ -459,7 +470,8 @@ class SRPAuth(QtCore.QObject): :type failure: twisted.python.failure.Failure """ logger.error("Error logging in %s" % (failure,)) - self.authentication_finished.emit(False, "%s" % (failure,)) + self.authentication_finished.emit(False, "%s" % (failure.value,)) + failure.trap(Exception) def get_session_id(self): return self.__instance.get_session_id() |