fix executing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from db import get_db
|
||||
import json
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
from flask import make_response
|
||||
|
||||
@@ -194,6 +194,14 @@ def get_pending_command():
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
# Free up stuck 'executing' commands (e.g. if the game page was refreshed mid-execution)
|
||||
two_minutes_ago = (datetime.utcnow() - timedelta(minutes=2)).isoformat()
|
||||
c.execute('''
|
||||
UPDATE commands
|
||||
SET status = 'pending', result_msg = 'Requeued (timeout)'
|
||||
WHERE status = 'executing' AND updated_at < ? AND player_id = ?
|
||||
''', (two_minutes_ago, player_id))
|
||||
|
||||
build_cmds = _fetch_pending_builds_all_towns(c, player_id) # one per town
|
||||
recruit_cmd = _fetch_pending_of_type(c, 'recruit', player_id)
|
||||
market_cmd = _fetch_pending_of_type(c, 'market_offer', player_id)
|
||||
|
||||
Reference in New Issue
Block a user