开发者

python3 Auto-logout after certain hour has passed

I have server application written in python3. It stores date and time of logi开发者_StackOverflow社区ns and logouts in sqlite3 database. What I need it to do is to check if a certain hour has passed eg. 23:00 and then write to database logout time eg. 24:00:00 to those users that haven't loged out yet (because at 23:00 it's obvious that they forgot to logout) . I don't really know how to code this.

Edit:OK I'll specify my question maybe I wrote it too general, I don't really want it to write somebody for me just a hint how to start. How is possible trigger function after certain hour has passed.


Depends how this program is being run. If it is only running when the user does something (such as a web app, which serves a request, then terminates), you might need to create another job which is run by say cron (in the unix world) which would fire off at 23:00 and see if there's anyone who's been logged on for 10+ hours but hasn't had recent activity. If on the other hand the server program is constantly running, you could look into something like the threading.Timer class to run a method at a specified time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜