'Shutdown the WSGI server. Wait for non deamon threads.'

def stop(self):

    _logger.info('Initiating    shutdown')
    _logger.info('Hit    CTRL-C    again    or    send    a    second    signal    to    force    the    shutdown.')
    if self.httpd:
        self.httpd.shutdown()
        self.close_socket(self.httpd.socket)
    me = threading.currentThread()
    _logger.debug('current    thread:    %r', me)
    for thread in threading.enumerate():
        _logger.debug('process    %r    (%r)', thread, thread.isDaemon())
        if ((thread != me) and (not thread.isDaemon()) and (thread.ident != self.main_thread_id)):
            while thread.isAlive():
                _logger.debug('join    and    sleep')
                thread.join(0.05)
                time.sleep(0.05)
    _logger.debug('--')
    odoo.modules.registry.Registry.delete_all()
    logging.shutdown()
