Esempio n. 1
0
    def run(self, addr=None, port=None, unix_socket=None, django_url=None):
        assert (addr and port) or unix_socket

        self._django_url = get_django_url(django_url)
        if self._django_url.scheme == "http+unix":
            raise ValueError("http+unix scheme not currently supported with the gevent courier")

        # Initialize Django
        django.setup()

        logger.info("Django-RT gevent courier server running on " + ":".join([str(addr), str(port)]))

        self._wsgi_server = server = WSGIServer((addr, port), self.application)
        try:
            server.serve_forever()
        except KeyboardInterrupt:
            pass
Esempio n. 2
0
    def run(self, addr=None, port=None, unix_socket=None, django_url=None):
        assert (addr and port) or unix_socket

        self._django_url = get_django_url(django_url)
        if self._django_url.scheme == 'http+unix':
            raise ValueError(
                'http+unix scheme not currently supported with the gevent courier'
            )

        # Initialize Django
        django.setup()

        logger.info('Django-RT gevent courier server running on ' +
                    ':'.join([str(addr), str(port)]))

        self._wsgi_server = server = WSGIServer((addr, port), self.application)
        try:
            server.serve_forever()
        except KeyboardInterrupt:
            pass
Esempio n. 3
0
    def run(self, addr=None, port=None, unix_socket=None, django_url=None):
        assert (addr and port) or unix_socket

        self._django_url = get_django_url(django_url)

        # Initialize Django
        django.setup()

        # Suppress the spammy asyncio logging
        logging.getLogger('asyncio').setLevel(logging.WARNING)

        # Run server
        loop = asyncio.get_event_loop()
        app = self.create_app(loop)
        handler = app.make_handler()
        if unix_socket:
            f = loop.create_unix_server(handler, unix_socket)
            listen_str = unix_socket
        else:
            f = loop.create_server(handler, addr, port)
            listen_str = ':'.join([str(addr), str(port)])
        logger.info('Django-RT asyncio courier server running on ' +
                    listen_str)
        srv = loop.run_until_complete(f)

        self._ev_loop = loop
        try:
            loop.run_forever()
        except KeyboardInterrupt:
            pass
        finally:
            # Shutdown
            self._ev_loop = None
            logger.info('Closing connections...')
            loop.run_until_complete(handler.finish_connections(1.0))
            srv.close()
            loop.run_until_complete(srv.wait_closed())
            loop.run_until_complete(app.finish())
            loop.close()
Esempio n. 4
0
    def run(self, addr=None, port=None, unix_socket=None, django_url=None):
        assert (addr and port) or unix_socket

        self._django_url = get_django_url(django_url)

        # Initialize Django
        django.setup()

        # Suppress the spammy asyncio logging
        logging.getLogger('asyncio').setLevel(logging.WARNING)

        # Run server
        loop = asyncio.get_event_loop()
        app = self.create_app(loop)
        handler = app.make_handler()
        if unix_socket:
            f = loop.create_unix_server(handler, unix_socket)
            listen_str = unix_socket
        else:
            f = loop.create_server(handler, addr, port)
            listen_str = ':'.join([str(addr), str(port)])
        logger.info('Django-RT asyncio courier server running on '+listen_str)
        srv = loop.run_until_complete(f)

        self._ev_loop = loop
        try:
            loop.run_forever()
        except KeyboardInterrupt:
            pass
        finally:
            # Shutdown
            self._ev_loop = None
            logger.info('Closing connections...')
            loop.run_until_complete(handler.finish_connections(1.0))
            srv.close()
            loop.run_until_complete(srv.wait_closed())
            loop.run_until_complete(app.finish())
            loop.close()