import sys sys.path.insert(0, '/home/ilia/twisted-jsonrpc') from adytum.twisted.web.jsonrpc import Proxy from twisted.internet import reactor class AccountBalance: def __init__(self): self.banks = ['pc', 'cibc-nurey', 'cibc-ilia'] self.reactorStopCnt = len(self.banks) self.cnt = 0 def printValue(self, value): self.callback(value) self.cnt = self.cnt + 1 if self.cnt == self.reactorStopCnt: reactor.stop() def printError(self, error): print 'error', error reactor.stop() def getAccountBalance(self, callback): self.callback = callback for bankId in self.banks: proxy = Proxy('http://localhost:8080/Finance/Bank/JSONFactory', 'TwistedJsonRpcClient_'+bankId) proxy.callRemote('accounts', {'bank_id': bankId, 'card_number': 'XXX', 'password': 'XXX', 'cache_path': '/home/ilia/byob/pages/cache'}).addCallbacks(self.printValue, self.printError) reactor.run()