|
|
@ -257,10 +257,15 @@ class Interface(util.PrintError): |
|
|
|
self.request_time = time.time() |
|
|
|
self.unsent_requests.append(args) |
|
|
|
|
|
|
|
def num_requests(self): |
|
|
|
'''Keep unanswered requests below 100''' |
|
|
|
n = 100 - len(self.unanswered_requests) |
|
|
|
return min(n, len(self.unsent_requests)) |
|
|
|
|
|
|
|
def send_requests(self): |
|
|
|
'''Sends queued requests. Returns False on failure.''' |
|
|
|
make_dict = lambda (m, p, i): {'method': m, 'params': p, 'id': i} |
|
|
|
n = 100 - len(self.unanswered_requests) |
|
|
|
n = self.num_requests() |
|
|
|
wire_requests = self.unsent_requests[0:n] |
|
|
|
try: |
|
|
|
self.pipe.send_all(map(make_dict, wire_requests)) |
|
|
|