'Call if there is data available on the socket.  Returns a list of
(request, response) pairs.  Notifications are singleton
unsolicited responses presumably as a result of prior
subscriptions, so request is None and there is no \'id\' member.
Otherwise it is a response, which has an \'id\' member and a
corresponding request.  If the connection was closed remotely
or the remote server is misbehaving, a (None, None) will appear.'

def get_responses(self):

    responses = []
    while True:
        try:
            response = self.pipe.get()
        except util.timeout:
            break
        if (not (type(response) is dict)):
            responses.append((None, None))
            if (response is None):
                self.closed_remotely = True
                self.print_error('connection    closed    remotely')
            break
        if self.debug:
            self.print_error('<--', response)
        wire_id = response.get('id', None)
        if (wire_id is None):
            responses.append((None, response))
        else:
            request = self.unanswered_requests.pop(wire_id, None)
            if request:
                responses.append((request, response))
            else:
                self.print_error('unknown    wire    ID', wire_id)
                responses.append((None, None))
                break
    return responses
