Skip to content

How to detect idle time on web page for auto logout? #1413

Closed Answered by falkoschindler
Anindya088 asked this question in Q&A
Discussion options

You must be logged in to vote
  1. background_tasks is a (undocumented) module for running tasks in the background, i.e. if you don't want to await their result. This is used internally for event handling, timers etc.
  2. Yes, that would be the idea. But I just got another idea: You could register a handler for every SocketIO event message.
    @globals.sio.on('event')
    def handle_event(sid: str, msg: dict):
        reset_deadline()
    But I guess these lines should be placed in the global scope where reset_deadline isn't defined (to avoid registering a new callback on every page visit). So you need to re-organize the code a bit.
  3. You can do something like this:
    client.page_container.on('mousemove', lambda e: print(e))

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Anindya088
Comment options

@falkoschindler
Comment options

Answer selected by Anindya088
@Anindya088
Comment options

@pclass-isolated
Comment options

@rodja
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants