Why session doesn't update or change when inside a loop? #1638
-
I have multiple event handlers, Session value get changed in a handler, other handlers can access the updated value and also able to change it successfully, Which can be successfully accessible from other handlers. Problem happen, when i wanted to stop a "for" loop, running inside a handler. So i made an another handler which set a stop value in session. Then i tried to access it inside that "for" loop. But the loop can't see the updated value. Then i tried to check if session was actually updated successfully by accessing it from other handlers. And yes it changed, i got the updated value. Only "for" loop can't see this. I tried to change value inside the "for" loop, it also didn't have any effect on session. other handler can't see that change. but only "for" loop can see its changed value. It's like "for" loop using a virtual session of its own. copy the main session before entering the loop, then disconnect it self completely with the session. Notes, I'm using filesystem session, session.modified is set after every change, all library is up to date. manage_session is False... If my words are not clear enough, I'll make a mwe. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
There is nothing special about a for loop. The only thing that can prevent the session from being saved is an exception, which would interrupt your handler. |
Beta Was this translation helpful? Give feedback.
There is nothing special about a for loop. The only thing that can prevent the session from being saved is an exception, which would interrupt your handler.