Пример #1
0
        Unblock streams waiting on flow control, if needed.
        """
        stream_id = event.stream_id

        if stream_id and stream_id in self.flow_control_events:
            evt = self.flow_control_events.pop(stream_id)
            await evt.set()
        elif not stream_id:
            # Need to keep a real list here to use only the events present at
            # this time.
            blocked_streams = list(self.flow_control_events.keys())
            for stream_id in blocked_streams:
                event = self.flow_control_events.pop(stream_id)
                await event.set()
        return


if __name__ == '__main__':
    host = sys.argv[2] if len(sys.argv) > 2 else "localhost"
    kernel = Kernel(with_monitor=True)
    kernel.add_task(h2_server((host, 5000),
                              sys.argv[1],
                              "{}.crt.pem".format(host),
                              "{}.key".format(host)))
    print("Try GETting:")
    print("    On OSX after 'brew install curl --with-c-ares --with-libidn --with-nghttp2 --with-openssl':")
    print("/usr/local/Cellar/curl/7.47.1/bin/curl --tlsv1.2 --http2 -k https://localhost:5000/bundle.js")
    print("Or open a browser to: https://localhost:5000/")
    print("   (Accept all the warnings)")
    kernel.run()
Пример #2
0
    async def wait_for_flow_control(self, stream_id):
        """
        Blocks until the flow control window for a given stream is opened.
        """
        evt = Event()
        self.flow_control_events[stream_id] = evt
        await evt.wait()

    async def window_updated(self, event):
        """
        Unblock streams waiting on flow control, if needed.
        """
        stream_id = event.stream_id

        if stream_id and stream_id in self.flow_control_events:
            evt = self.flow_control_events.pop(stream_id)
            await evt.set()
        elif not stream_id:
            for evt in self.flow_control_events.values():
                await evt.set()

            self.flow_control_events = {}

        return


if __name__ == '__main__':
    kernel = Kernel()
    kernel.add_task(h2_server(('', 8080), sys.argv[1]))
    kernel.run()
Пример #3
0
    async def wait_for_flow_control(self, stream_id):
        """
        Blocks until the flow control window for a given stream is opened.
        """
        evt = Event()
        self.flow_control_events[stream_id] = evt
        await evt.wait()

    async def window_updated(self, event):
        """
        Unblock streams waiting on flow control, if needed.
        """
        stream_id = event.stream_id

        if stream_id and stream_id in self.flow_control_events:
            evt = self.flow_control_events.pop(stream_id)
            await evt.set()
        elif not stream_id:
            for evt in self.flow_control_events.values():
                await evt.set()

            self.flow_control_events = {}

        return


if __name__ == '__main__':
    kernel = Kernel()
    kernel.add_task(h2_server(('', 8080), sys.argv[1]))
    kernel.run()
Пример #4
0
        if stream_id and stream_id in self.flow_control_events:
            evt = self.flow_control_events.pop(stream_id)
            await evt.set()
        elif not stream_id:
            # Need to keep a real list here to use only the events present at
            # this time.
            blocked_streams = list(self.flow_control_events.keys())
            for stream_id in blocked_streams:
                event = self.flow_control_events.pop(stream_id)
                await event.set()
        return


if __name__ == '__main__':
    host = sys.argv[2] if len(sys.argv) > 2 else "localhost"
    kernel = Kernel(with_monitor=True)
    kernel.add_task(
        h2_server((host, 5000), sys.argv[1], "{}.crt.pem".format(host),
                  "{}.key".format(host)))
    print("Try GETting:")
    print(
        "    On OSX after 'brew install curl --with-c-ares --with-libidn --with-nghttp2 --with-openssl':"
    )
    print(
        "/usr/local/Cellar/curl/7.47.1/bin/curl --tlsv1.2 --http2 -k https://localhost:5000/bundle.js"
    )
    print("Or open a browser to: https://localhost:5000/")
    print("   (Accept all the warnings)")
    kernel.run()