summaryrefslogtreecommitdiff
path: root/src/leap/crypto
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-06-14 12:45:08 -0300
committerTomás Touceda <chiiph@leap.se>2013-06-14 12:45:08 -0300
commit8bee5f4e9a1bb0f7069fe41ab37dfec000487d7b (patch)
treeaced8cb3ba7b9d6db54740fbaf327144008b22b9 /src/leap/crypto
parent733343465354e52e33dfe14aca54ebb7b786f5dd (diff)
Actually deferToThread all the things we expect to do in parallel
Diffstat (limited to 'src/leap/crypto')
-rw-r--r--src/leap/crypto/srpauth.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/leap/crypto/srpauth.py b/src/leap/crypto/srpauth.py
index d089fa50..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