Fix backend detection in testing runners - #3944
Conversation
T4rk1n
left a comment
There was a problem hiding this comment.
Looks good, just some minor comments and need to add a changelog entry.
| server_type = getattr(getattr(app, "backend", None), "server_type", "flask") | ||
| if server_type in ("fastapi", "quart"): | ||
| app.run(**options) | ||
| else: | ||
| app.run(threaded=True, **options) |
There was a problem hiding this comment.
We lost the comments indicating that we need the threaded=True for flask testing.
|
|
||
|
|
||
| def _run_app(app, options): | ||
| server_type = getattr(getattr(app, "backend", None), "server_type", "flask") |
There was a problem hiding this comment.
This is duplicated code at line 221-222, could potentially extract that into a _server_type function to prevent drift.
|
Addressed the review feedback:
Verification:
Note: the full |
|



Fixes #3942.
ThreadedRunnerandMultiProcessRunnerdetermined whether to pass Flask'sthreaded=Trueoption by inspecting the concrete server class module. That misclassified wrapped or subclassed FastAPI/Quart servers whose classes are defined elsewhere.Use Dash's already-resolved
app.backend.server_typeinstead, while preserving the Flask fallback. The regression coverage includes a wrapped FastAPI-shaped server and the FastAPI, Quart, and Flask option paths.Contributor Checklist
optionals
CHANGELOG.mdLocal verification
python -m pytest tests/unit/test_app_runners.py -k 'wrapped_fastapi or uses_backend_type' -q— 4 passedpython -m pytest tests/unit/test_testing.py -q— 1 passedgit diff --check