

def _begin_new_stream(self, stream_id, allowed_ids):
    '\n        Initiate a new stream.\n\n        .. versionchanged:: 2.0.0\n           Removed this function from the public API.\n\n        :param stream_id: The ID of the stream to open.\n        :param allowed_ids: What kind of stream ID is allowed.\n        '
    outbound = self._stream_id_is_outbound(stream_id)
    highest_stream_id = (self.highest_outbound_stream_id if outbound else self.highest_inbound_stream_id)
    if (stream_id <= highest_stream_id):
        raise StreamIDTooLowError(stream_id, highest_stream_id)
    if ((stream_id % 2) != int(allowed_ids)):
        raise ProtocolError('Invalid stream ID for peer.')
    s = H2Stream(stream_id)
    s.max_inbound_frame_size = self.max_inbound_frame_size
    s.max_outbound_frame_size = self.max_outbound_frame_size
    s.outbound_flow_control_window = self.remote_settings.initial_window_size
    s.inbound_flow_control_window = self.local_settings.initial_window_size
    self.streams[stream_id] = s
    if outbound:
        self.highest_outbound_stream_id = stream_id
    else:
        self.highest_inbound_stream_id = stream_id
    return s

dataset/ETHPy150Open python-hyper/hyper-h2/h2/connection.py H2Connection._begin_new_stream/original