Permalink
Browse files

Lock the HTTP thread

  • Loading branch information...
1 parent 085b630 commit e22aadea851ee1aa48ca9581d72f413596bc4f08 @CFSworks CFSworks committed Nov 3, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 minerutil/RPCProtocol.py
View
@@ -34,6 +34,12 @@ class ServerMessage(Exception): pass
class HTTPBase(object):
connection = None
timeout = None
+ lock = None
+
+ def doRequest(self, *args):
+ if self.lock is None:
+ self.lock = defer.DeferredLock()
+ return self.lock.run(threads.deferToThread, self._doRequest, *args)
def _doRequest(self, url, *args):
if self.connection is None:
@@ -126,7 +132,7 @@ def call(self, method, params=[]):
path = self.root.url.path or '/'
if self.root.url.query:
path += '?' + self.root.url.query
- response = yield threads.deferToThread(self._doRequest,
+ response = yield self.doRequest(
self.root.url,
'POST',
path,
@@ -179,7 +185,7 @@ def _request(self):
path = self.url.path or '/'
if self.url.query:
path += '?' + self.url.query
- d = threads.deferToThread(self._doRequest,
+ d = yield self.doRequest(
self.url,
'GET',
path,

0 comments on commit e22aade

Please sign in to comment.