fix blueprint registering and double init#3798
Conversation
There was a problem hiding this comment.
Rather than add these blueprint checks for each backend, what if you add a check in init_app to see if the same server has already been registered? If the same server is passed in, then it becomes a no-op. If it's a new server, then the init takes place with the new server.
If you go with the current per backend approach, certain calls would add duplicate handlers or attempt to register the same routes again:
self.backend.before_request(self._setup_server)
...
self._setup_routes()
|
There was a problem hiding this comment.
You could revert this change and get rid of this file from the PR.
There was a problem hiding this comment.
I asked Claude to write a test that would look at the idempotency when calling init twice. This might be worth adding:
def test_init_app_idempotent_on_same_server():
external = Flask("ext")
app = Dash(__name__, server=False)
app.init_app(external)
app.init_app(external) # must not raise
# request still works
client = external.test_client()
assert client.get("/").status_code == 200


Fix #3787