(self)
| 79 | return trans |
| 80 | |
| 81 | def poll_once(self): |
| 82 | self.sock.settimeout(self.timeout) |
| 83 | try: |
| 84 | response = self.sock.recv(10240) |
| 85 | except socket.timeout: |
| 86 | return |
| 87 | |
| 88 | header = response[:8] |
| 89 | payload = response[8:] |
| 90 | action, trans_id = struct.unpack('!LL', header) |
| 91 | try: |
| 92 | trans = self.transactions[trans_id] |
| 93 | except KeyError: |
| 94 | self.error('transaction_id not found') |
| 95 | return |
| 96 | trans['response'] = self._process_response(action, payload, trans) |
| 97 | trans['completed'] = True |
| 98 | del self.transactions[trans_id] |
| 99 | return trans |
| 100 | |
| 101 | def error(self, message): |
| 102 | raise Exception('error: {}'.format(message)) |
no test coverage detected