Przeglądaj źródła

fix: `defer_call()` call order

wangweimin 5 lat temu
rodzic
commit
526230abc8

+ 2 - 0
pywebio/session/coroutinebased.py

@@ -168,6 +168,8 @@ class CoroutineBasedSession(AbstractSession):
             return
         self._closed = True
         self._cleanup()
+
+        self.deferred_functions.reverse()
         while self.deferred_functions:
             func = self.deferred_functions.pop()
             catch_exp_call(func, logger)

+ 1 - 0
pywebio/session/threadbased.py

@@ -195,6 +195,7 @@ class ThreadBasedSession(AbstractSession):
 
         self._cleanup()
 
+        self.deferred_functions.reverse()
         while self.deferred_functions:
             func = self.deferred_functions.pop()
             catch_exp_call(func, logger)