mirror of https://github.com/explosion/spaCy.git
Shut down displaCy server on KeyboardInterrupt
This commit is contained in:
parent
70fbba7d08
commit
cc8c8617a4
|
@ -56,7 +56,12 @@ def serve(docs, style='dep', page=True, minify=False, options={}, manual=False,
|
||||||
render(docs, style=style, page=page, minify=minify, options=options, manual=manual)
|
render(docs, style=style, page=page, minify=minify, options=options, manual=manual)
|
||||||
httpd = simple_server.make_server('0.0.0.0', port, app)
|
httpd = simple_server.make_server('0.0.0.0', port, app)
|
||||||
prints("Using the '%s' visualizer" % style, title="Serving on port %d..." % port)
|
prints("Using the '%s' visualizer" % style, title="Serving on port %d..." % port)
|
||||||
|
try:
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
prints("Shutting down server on port %d." % port)
|
||||||
|
finally:
|
||||||
|
httpd.server_close()
|
||||||
|
|
||||||
|
|
||||||
def app(environ, start_response):
|
def app(environ, start_response):
|
||||||
|
|
Loading…
Reference in New Issue