diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:57:26 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:57:26 +0200 |
commit | 07c2b124e4348b15f1e5ec18c6cdfd77248c6bc8 (patch) | |
tree | e4a29123d3ebedc1d25500390c904c66b3b02489 /api/game/cleanup.py | |
parent | aa2c999702dadba2afbcf2be9f597f890aafcc87 (diff) |
spaces > tabs in python :(
Diffstat (limited to 'api/game/cleanup.py')
-rw-r--r-- | api/game/cleanup.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/api/game/cleanup.py b/api/game/cleanup.py index cc0aab8..8f7266d 100644 --- a/api/game/cleanup.py +++ b/api/game/cleanup.py @@ -5,26 +5,26 @@ 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() - for game_id in old_games: - cursor.execute("delete from games where game_id = ?", [game_id[0]]) - connection.commit() + 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() + for game_id in old_games: + cursor.execute("delete from games where game_id = ?", [game_id[0]]) + connection.commit() def set_interval( - func, sec + func, sec ): # https://stackoverflow.com/questions/2697039/python-equivalent-of-setinterval - def func_wrapper(): - set_interval(func, sec) - func() + def func_wrapper(): + set_interval(func, sec) + func() - t = threading.Timer(sec, func_wrapper) - t.start() - return t + t = threading.Timer(sec, func_wrapper) + t.start() + return t # run every five minutes |