Esempio n. 1
0
    def _serve(self, max_workers, port, *args, **kwargs):
        from django.conf import settings

        config = getattr(settings, "GRPCSERVER", dict())

        autoreload.raise_last_exception()
        self.stdout.write("Starting server at %s" % datetime.datetime.now())

        if not config.get("authentication"):
            self.stdout.write("Starting basic grpcserver")
            server = create_server(max_workers, port)
        elif config.get("authentication") == "ssl":
            self.stdout.write("Starting ssl grpcserver")
            server = create_ssl_server(max_workers, port)
        server.start()

        self.stdout.write("Server is listening port %s" % port)

        if kwargs["list_handlers"] is True:
            self.stdout.write("Registered handlers:")
            for handler in extract_handlers(server):
                self.stdout.write("* %s" % handler)

        # since server.start() will not block,
        # a sleep-loop is added to keep alive
        try:
            while True:
                time.sleep(86400)
        except KeyboardInterrupt:
            server.stop(0)
            sys.exit(0)
Esempio n. 2
0
    def _serve(self, max_workers, port, *args, **kwargs):
        autoreload.raise_last_exception()
        self.stdout.write("Starting server at %s" % datetime.datetime.now())

        server = create_server(max_workers, port)
        server.start()

        self.stdout.write("Server is listening port %s" % port)

        if kwargs['list_handlers'] is True:
            self.stdout.write("Registered handlers:")
            for handler in extract_handlers(server):
                self.stdout.write("* %s" % handler)

        server.wait_for_termination()
Esempio n. 3
0
    def _serve(self, max_workers, port, *args, **kwargs):
        autoreload.raise_last_exception()
        self.stdout.write("Starting server at %s" % datetime.datetime.now())

        server = create_server(max_workers, port)
        server.start()

        self.stdout.write("Server is listening port %s" % port)

        if kwargs['list_handlers'] is True:
            self.stdout.write("Registered handlers:")
            for handler in extract_handlers(server):
                self.stdout.write("* %s" % handler)

        # since server.start() will not block,
        # a sleep-loop is added to keep alive
        try:
            while True:
                time.sleep(86400)
        except KeyboardInterrupt:
            server.stop(0)
            sys.exit(0)
Esempio n. 4
0
def test_extract_handlers():
    server = create_server(1, 50080)
    assert list(extract_handlers(server)) == ['Greeter.SayHello']
Esempio n. 5
0
def test_extract_handlers():
    server = create_server(1, 50080)
    assert list(extract_handlers(server)) == [
        '/helloworld.Greeter/SayHello: inner(args, kwargs, response, exc) NOT IMPLEMENTED',
    ]