소스 검색

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)