self.db.auction_end()
скрипт сайта полностью перестает работать. Так же функция self.db.auction_end() выполняется не до конца ( после print(5) нет print(6) ). print(1)
sql = "SELECT * FROM auction ORDER BY summ DESC"
self.cur.execute(sql)
resp = self.cur.fetchall()
print(2)
user = self.get_row("users", "*", f"id=%s", resp[0]['user_id'])[0]
if len(resp) == 0:
print(" NUUUUUUUUUUUUUUUUUUUUUUUUUUUUULLLLL")
return
summ = 0
for i in resp:
summ += int(i['summ'])
resp = resp[0]
summ = summ - summ / 100 * 20
win_summ = int(summ)
summ = summ + int(user['score'])
summ = int(summ)
print(3)
self.update_score(summ, resp['user_id'], 2, "Победа в аукционе")
print(4)
self.cur.execute("DELETE FROM auction")
print(5)
self.conn.commit()
print(6)
last_win = self.get_row("last_winners")
time = datetime.now().strftime("%d.%m.%Y %H:%M:%S")
print(len(last_win))
if len(last_win) < 3:
print("y")
self.add_row("last_winners", login=user['login'], summ=win_summ, time=time, img=user['image'])
elif len(last_win) == 3:
sql = """DELETE FROM last_winners WHERE id in(SELECT MIN(id) FROM last_winners) """
self.cur.execute(sql)
self.conn.commit()
self.add_row("last_winners", login=user['login'], summ=win_summ, time=time, img=user['image'])
class Auction(Thread):
db = DataBase()
def __init__(self) -> None:
Thread.__init__(self)
def run(self):
while True:
sleep(3)
timer = self.db.get_row("timer")[0]
time = datetime.strptime(timer['start_time'], "%d.%m.%Y %H:%M:%S")
time_1 = time - timedelta( seconds=60)
time = time + timedelta(minutes=3, seconds=30)
time_2 = datetime.now()
if timer['active'] == 1:
if time_1 <= time_2:
print("end")
self.db.update_row("timer", active=0)
self.db.auction_end()
continue
if time <= time_2 and timer['active'] == 0:
respones = {"name": "Bot", "summ": 50}
socketio.emit("add_bet", respones, namespace='/app/auction', room="1")
now = datetime.now().strftime("%d.%m.%Y %H:%M:%S")
self.db.update_row("timer", start_time=now, active=1)
self.db.auction_update(24, 50)
continue
continue
t = Auction()
t.start()