简体   繁体   中英

How to monitor a variable in python?

I have a simple python flask project in which I need to have a user confirmation before any action can take place.

...
#need to confirm from the user before the action takes place. If it is yes, continue with action(), else skip action
#I need to keep monitoring the confirm_var here
action()
...

After getting confirmation from the user, I am calling this confirmation() function to set the confirm_var using AJAX call.

def confirmation()
    #set confirm_var to yes/no depending on user input.

So, my question is how to keep monitoring the confirm_var .

You could use write your own event with a wait function. Wait is more CPU hungry but it is more responsive. See here for example. But it depends on your python version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM