'Attaches a stream to a circuit.
Note: Tor attaches streams to circuits automatically unless the
__LeaveStreamsUnattached configuration variable is set to \'1\'
:param str stream_id: id of the stream that must be attached
:param str circuit_id: id of the circuit to which it must be attached
:param int exiting_hop: hop in the circuit where traffic should exit
:raises:
* :class:`stem.InvalidRequest` if the stream or circuit id were unrecognized
* :class:`stem.UnsatisfiableRequest` if the stream isn\'t in a state where it can be attached
* :class:`stem.OperationFailed` if the stream couldn\'t be attached for any other reason'

def attach_stream(self, stream_id, circuit_id, exiting_hop=None):

    query = ('ATTACHSTREAM    %s    %s' % (stream_id, circuit_id))
    if exiting_hop:
        query += ('    HOP=%s' % exiting_hop)
    response = self.msg(query)
    stem.response.convert('SINGLELINE', response)
    if (not response.is_ok()):
        if (response.code == '552'):
            raise stem.InvalidRequest(response.code, response.message)
        elif (response.code == '551'):
            raise stem.OperationFailed(response.code, response.message)
        elif (response.code == '555'):
            raise stem.UnsatisfiableRequest(response.code, response.message)
        else:
            raise stem.ProtocolError(('ATTACHSTREAM    returned    unexpected    response    code:    %s' % response.code))
