Bottle web framework - How to stop?

前端 未结 11 1305
不知归路
不知归路 2020-12-14 06:55

When starting a bottle webserver without a thread or a subprocess, there\'s no problem. To exit the bottle app -> CTRL + c.

In a thread, ho

11条回答
  •  佛祖请我去吃肉
    2020-12-14 07:43

    Here's one option: provide custom server (same as default), that records itself:

    import bottle
    
    
    class WSGI(bottle.WSGIRefServer):
        instances = []
    
        def run(self, *args, **kw):
            self.instances.append(self)
            super(WSGI, self).run(*args, **kw)
    
    # some other thread:
    bottle.run(host=ip_address, port=12345, server=WSGI)
    
    # control thread:
    logging.warn("servers are %s", WSGI.instances)
    

提交回复
热议问题