Skip to content

Commit ab4298b

Browse files
committed
refine error msg in session deferred calls
1 parent 08dfd17 commit ab4298b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pywebio/session/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from collections import defaultdict
55

66
import user_agents
7-
8-
from ..utils import catch_exp_call
7+
from ..exceptions import SessionException
98

109
logger = logging.getLogger(__name__)
1110

@@ -119,7 +118,13 @@ def close(self, nonblock=False):
119118
self.deferred_functions.reverse()
120119
while self.deferred_functions:
121120
func = self.deferred_functions.pop()
122-
catch_exp_call(func, logger)
121+
try:
122+
func()
123+
except Exception as e:
124+
msg = "Error occurred when running deferred function %s" % func
125+
if isinstance(e, SessionException):
126+
msg = "PyWebIO interactive functions cannot be called inside the deferred functions."
127+
logger.exception(msg)
123128

124129
def closed(self) -> bool:
125130
return self._closed

0 commit comments

Comments
 (0)