mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 16:17:57 +01:00
Fix duplicating server on ui reload
This commit is contained in:
parent
0cbe2dd7e9
commit
bd27353a08
@ -8,6 +8,8 @@ params = {
|
|||||||
'port': 5000,
|
'port': 5000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server = None
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
class Handler(BaseHTTPRequestHandler):
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
if self.path == '/api/v1/model':
|
if self.path == '/api/v1/model':
|
||||||
@ -73,6 +75,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
|
|
||||||
def run_server():
|
def run_server():
|
||||||
|
global server
|
||||||
server_addr = ('0.0.0.0' if shared.args.listen else '127.0.0.1', params['port'])
|
server_addr = ('0.0.0.0' if shared.args.listen else '127.0.0.1', params['port'])
|
||||||
server = ThreadingHTTPServer(server_addr, Handler)
|
server = ThreadingHTTPServer(server_addr, Handler)
|
||||||
if shared.args.share:
|
if shared.args.share:
|
||||||
@ -87,4 +90,5 @@ def run_server():
|
|||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
||||||
def ui():
|
def ui():
|
||||||
|
if server is None:
|
||||||
Thread(target=run_server, daemon=True).start()
|
Thread(target=run_server, daemon=True).start()
|
Loading…
Reference in New Issue
Block a user