From bc3707e854fa313aa0a812fdada78ea3a8a2425c Mon Sep 17 00:00:00 2001 From: xuhaidong Date: Thu, 6 Jun 2024 17:53:06 +0800 Subject: [PATCH] feat: guarantee extensions order --- sea/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sea/app.py b/sea/app.py index c7231e2..418837b 100644 --- a/sea/app.py +++ b/sea/app.py @@ -137,7 +137,10 @@ def load_extensions_in_module(self, module): def is_ext(ins): return not inspect.isclass(ins) and hasattr(ins, "init_app") - for n, ext in inspect.getmembers(module, is_ext): + for n, ext in sorted( + inspect.getmembers(module, is_ext), + key=lambda x: getattr(x[1], "load_order", 0), + ): self._register_extension(n, ext) return self.extensions