How to use the priority.priority.TooManyStreamsError function in priority

To help you get started, we’ve selected a few priority examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookexperimental / doh-proxy / dohproxy / client_protocol.py View on Github external
]
        if self.args.post:
            headers.append(('content-type', constants.DOH_MEDIA_TYPE))
            body = dnsq.to_wire()
        else:
            path = self._make_get_path(dnsq.to_wire())

        headers.insert(0, (':path', path))
        headers.extend([
            ('content-length', str(len(body))),
        ])
        # Start request with headers
        # FIXME: Find a better way to close old streams. See GH#11
        try:
            stream_id = await self.on_start_request(client, headers, not body)
        except priority.priority.TooManyStreamsError:
            await self.setup_client()
            client = self.client
            stream_id = await self.on_start_request(client, headers, not body)
        self.logger.debug(
            'Stream ID: {} / Total streams: {}'.format(
                stream_id, len(client._streams)
            )
        )
        # Send my name "world" as whole request body
        if body:
            await self.on_send_data(client, stream_id, body)

        # Receive response headers
        headers = await client.recv_response(stream_id)
        self.on_recv_response(stream_id, headers)
        # FIXME handled error with servfail
github URenko / Accesser / utils / DoH.py View on Github external
(':method', self.args.post and 'POST' or 'GET'),
            (':scheme', 'https'),
        ]
        if self.args.post:
            headers.append(('content-type', constants.DOH_MEDIA_TYPE))
            body = dnsq.to_wire()
        else:
            path = self._make_get_path(dnsq.to_wire())

        headers.insert(0, (':path', path))
        headers.extend([
            ('content-length', str(len(body))),
        ])
        try:
            stream_id = await self.on_start_request(client, headers, not body)
        except priority.priority.TooManyStreamsError:
            await self.setup_client()
            client = self.client
            stream_id = await self.on_start_request(client, headers, not body)
        if body:
            await self.on_send_data(client, stream_id, body)

        headers = await client.recv_response(stream_id)
        self.on_recv_response(stream_id, headers)

        resp = await client.read_stream(stream_id, -1)
        return self.on_message_received(stream_id, resp)