plugin/server.py
def shutdown(self, hard=False, timeout=None):
        '''
        Shuts down all managed servers.

        If `hard` is true, then the server processes will be killed via a kill
        signal instead of the standard shutdown http request. If `timeout` is
        omitted, this method waits indefinitely for the process to exit.
        Otherwise, each server process is given `timeout` seconds to exit. If
        a process does not exit within the timeout, then it will be ignored.
        This is not ideal, as it may result in zombie processes.

        If `hard` is false, then the servers will be shut down gracefully using
        the shutdown http handler. If `timeout` is omitted, this method waits
        indefinitely for the servers to shut down. Otherwise, each server is
        given `timeout` seconds to shutdown gracefully. If it fails to shut
        down in that time, this method returns without doing anything extra.

        The return value will be true if all servers were successfully shut
        down, and false otherwise. This can be useful when attempting to do
        a graceful shutdown followed by a hard shutdown if any servers remain.
        '''
        if hard:
            def shutdown_server(server):
                assert isinstance(server, Server), \
                    '[internal] server is not a Server: %r' % (server)
                server.kill()
                server.wait(timeout=timeout)
                return server
        else:
            def shutdown_server(server):
                assert isinstance(server, Server), \
                    '[internal] server is not a Server: %r' % (server)
                server.stop(timeout=timeout)
                return server

        if not self._servers:
            # no servers to shutdown, so done
            logger.debug('no servers to shut down, done')
            return True

        shutdown_futures = [
            self._task_pool.submit(shutdown_server, server)
            for server in self._servers
        ]
        finished_futures, unfinished_futures = concurrent.futures.wait(
            shutdown_futures, timeout=timeout,
        )

        all_shutdown_successfully = True
        # unregister servers that were successfully shutdown
        for finished_future in finished_futures:
            assert finished_future.done(), \
                '[internal] finished future is not actually finished: %r' % \
                (finished_future)
            if finished_future.exception(timeout=0) is None:
                # `shutdown_server` returns the specific server instance that
                # was shut down, so grab it from the future
                stopped_server = finished_future.result(timeout=0)
                assert isinstance(stopped_server, Server), \
                    '[internal] async shutdown did not return a Server: %r' % \
                    (stopped_server)
                assert stopped_server in self._servers, \
                    '[internal] server is not in managed server set: %r' % \
                    (stopped_server)

                logger.debug('server has shut down: %r', stopped_server)
                self._unregister_server(stopped_server)
            else:
                all_shutdown_successfully = False

        if unfinished_futures:
            all_shutdown_successfully = False

        return all_shutdown_successfully

        Shuts down all managed servers.

        If `hard` is true, then the server processes will be killed via a kill
        signal instead of the standard shutdown http request. If `timeout` is
        omitted, this method waits indefinitely for the process to exit.
        Otherwise, each server process is given `timeout` seconds to exit. If
        a process does not exit within the timeout, then it will be ignored.
        This is not ideal, as it may result in zombie processes.

        If `hard` is false, then the servers will be shut down gracefully using
        the shutdown http handler. If `timeout` is omitted, this method waits
        indefinitely for the servers to shut down. Otherwise, each server is
        given `timeout` seconds to shutdown gracefully. If it fails to shut
        down in that time, this method returns without doing anything extra.

        The return value will be true if all servers were successfully shut
        down, and false otherwise. This can be useful when attempting to do
        a graceful shutdown followed by a hard shutdown if any servers remain.
        
Shuts down all managed servers.
If `hard` is true, then the server processes will be killed via a kill
signal instead of the standard shutdown http request. If `timeout` is
omitted, this method waits indefinitely for the process to exit.
Otherwise, each server process is given `timeout` seconds to exit. If
a process does not exit within the timeout, then it will be ignored.
This is not ideal, as it may result in zombie processes.

If `hard` is false, then the servers will be shut down gracefully using
the shutdown http handler. If `timeout` is omitted, this method waits
indefinitely for the servers to shut down. Otherwise, each server is
given `timeout` seconds to shutdown gracefully. If it fails to shut
down in that time, this method returns without doing anything extra.

The return value will be true if all servers were successfully shut
down, and false otherwise. This can be useful when attempting to do
a graceful shutdown followed by a hard shutdown if any servers remain.
Shuts down all managed servers . If ` hard ` is true then the server processes will be killed via a kill signal instead of the standard shutdown http request . If ` timeout ` is omitted this method waits indefinitely for the process to exit . Otherwise each server process is given ` timeout ` seconds to exit . If a process does not exit within the timeout then it will be ignored . This is not ideal as it may result in zombie processes . If ` hard ` is false then the servers will be shut down gracefully using the shutdown http handler . If ` timeout ` is omitted this method waits indefinitely for the servers to shut down . Otherwise each server is given ` timeout ` seconds to shutdown gracefully . If it fails to shut down in that time this method returns without doing anything extra . The return value will be true if all servers were successfully shut down and false otherwise . This can be useful when attempting to do a graceful shutdown followed by a hard shutdown if any servers remain .
def shutdown(self, hard=False, timeout=None):
        if hard:
            def shutdown_server(server):
                assert isinstance(server, Server), \
                    '[internal] server is not a Server: %r' % (server)
                server.kill()
                server.wait(timeout=timeout)
                return server
        else:
            def shutdown_server(server):
                assert isinstance(server, Server), \
                    '[internal] server is not a Server: %r' % (server)
                server.stop(timeout=timeout)
                return server
        if not self._servers:
            logger.debug('no servers to shut down, done')
            return True
        shutdown_futures = [
            self._task_pool.submit(shutdown_server, server)
            for server in self._servers
        ]
        finished_futures, unfinished_futures = concurrent.futures.wait(
            shutdown_futures, timeout=timeout,
        )
        all_shutdown_successfully = True
        for finished_future in finished_futures:
            assert finished_future.done(), \
                '[internal] finished future is not actually finished: %r' % \
                (finished_future)
            if finished_future.exception(timeout=0) is None:
                stopped_server = finished_future.result(timeout=0)
                assert isinstance(stopped_server, Server), \
                    '[internal] async shutdown did not return a Server: %r' % \
                    (stopped_server)
                assert stopped_server in self._servers, \
                    '[internal] server is not in managed server set: %r' % \
                    (stopped_server)
                logger.debug('server has shut down: %r', stopped_server)
                self._unregister_server(stopped_server)
            else:
                all_shutdown_successfully = False
        if unfinished_futures:
            all_shutdown_successfully = False
        return all_shutdown_successfully
def shutdown ( self , hard = False , timeout = None ) : if hard : def shutdown_server ( server ) : assert isinstance ( server , Server ) , '[internal] server is not a Server: %r' % ( server ) server . kill ( ) server . wait ( timeout = timeout ) return server else : def shutdown_server ( server ) : assert isinstance ( server , Server ) , '[internal] server is not a Server: %r' % ( server ) server . stop ( timeout = timeout ) return server if not self . _servers : logger . debug ( 'no servers to shut down, done' ) return True shutdown_futures = [ self . _task_pool . submit ( shutdown_server , server ) for server in self . _servers ] finished_futures , unfinished_futures = concurrent . futures . wait ( shutdown_futures , timeout = timeout , ) all_shutdown_successfully = True for finished_future in finished_futures : assert finished_future . done ( ) , '[internal] finished future is not actually finished: %r' % ( finished_future ) if finished_future . exception ( timeout = 0 ) is None : stopped_server = finished_future . result ( timeout = 0 ) assert isinstance ( stopped_server , Server ) , '[internal] async shutdown did not return a Server: %r' % ( stopped_server ) assert stopped_server in self . _servers , '[internal] server is not in managed server set: %r' % ( stopped_server ) logger . debug ( 'server has shut down: %r' , stopped_server ) self . _unregister_server ( stopped_server ) else : all_shutdown_successfully = False if unfinished_futures : all_shutdown_successfully = False return all_shutdown_successfully
Shuts down all managed servers.
Shuts down all managed servers .
'''
        Shuts down all managed servers.

        If `hard` is true, then the server processes will be killed via a kill
        signal instead of the standard shutdown http request. If `timeout` is
        omitted, this method waits indefinitely for the process to exit.
        Otherwise, each server process is given `timeout` seconds to exit. If
        a process does not exit within the timeout, then it will be ignored.
        This is not ideal, as it may result in zombie processes.

        If `hard` is false, then the servers will be shut down gracefully using
        the shutdown http handler. If `timeout` is omitted, this method waits
        indefinitely for the servers to shut down. Otherwise, each server is
        given `timeout` seconds to shutdown gracefully. If it fails to shut
        down in that time, this method returns without doing anything extra.

        The return value will be true if all servers were successfully shut
        down, and false otherwise. This can be useful when attempting to do
        a graceful shutdown followed by a hard shutdown if any servers remain.
        ''' # no servers to shutdown, so done # unregister servers that were successfully shutdown # `shutdown_server` returns the specific server instance that # was shut down, so grab it from the future
self
hard
timeout