mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Fix #628: Flask tests fail because werkzeug.server.shutdown is deprecated
Use @app.teardown_request to exit asynchronously after serving the response.
This commit is contained in:
parent
983d14f9fd
commit
0a7f2cd67d
1 changed files with 9 additions and 6 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import os
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
exiting = False
|
||||
|
||||
|
||||
@app.route("/")
|
||||
|
|
@ -34,10 +36,11 @@ def bad_template():
|
|||
|
||||
@app.route("/exit")
|
||||
def exit_app():
|
||||
from flask import request
|
||||
|
||||
func = request.environ.get("werkzeug.server.shutdown")
|
||||
if func is None:
|
||||
raise RuntimeError("No shutdown")
|
||||
func()
|
||||
global exiting
|
||||
exiting = True
|
||||
return "Done"
|
||||
|
||||
@app.teardown_request
|
||||
def teardown(exception):
|
||||
if exiting:
|
||||
os._exit(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue