diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-28 12:19:28 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-28 12:19:28 +0200 |
commit | 2f4536d6b08b69168ebf3e718cbd8e3002b9af5a (patch) | |
tree | 5307692fb341d7f924ee9b73f3751e7e56cfb192 /api/game/cleanup.py | |
parent | 1f897d3f5ad11178cf4776ae4070c9d3e832f5f3 (diff) |
added comments
Diffstat (limited to 'api/game/cleanup.py')
-rw-r--r-- | api/game/cleanup.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/api/game/cleanup.py b/api/game/cleanup.py index 3c285e1..0a9aa46 100644 --- a/api/game/cleanup.py +++ b/api/game/cleanup.py @@ -2,6 +2,7 @@ from db import cursor, connection import threading import time +# cleanup function that's ran every five minutes def cleanup(): now = int( time.time() * 1000 ) old_games = cursor.execute("select game_id from games where (status = \"wait_for_opponent\" or status = \"in_progress\") and last_activity < ?", [now - 5 * 60 * 1e3]).fetchall() @@ -17,5 +18,6 @@ def set_interval(func, sec): # https://stackoverflow.com/questions/2697039/pytho t.start() return t +# run every five minutes set_interval(cleanup, 5 * 60) |