Parcourir la source

fix: `defer_call()` call order

wangweimin il y a 5 ans
Parent
commit
526230abc8
2 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 2 0
      pywebio/session/coroutinebased.py
  2. 1 0
      pywebio/session/threadbased.py

+ 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)