瀏覽代碼

fix: `defer_call()` call order

wangweimin 5 年之前
父節點
當前提交
526230abc8
共有 2 個文件被更改,包括 3 次插入0 次删除
  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)