#question regarding tasks

1 messages · Page 1 of 1 (latest)

bright axle
#

Code section in question:


@tasks.loop(seconds=120)
async def update_rpg_games():
    print("Triggering update now")
    last_timestamp = conn.execute("SELECT * FROM last_timestamp WHERE type='RPG'")
    last_timestamp = last_timestamp.fetchone()
    if last_timestamp is None:
        current_timestamp = int(round(time.time()))
        conn.execute(f"INSERT INTO last_timestamp VALUES ('RPG', {current_timestamp})")
        conn.commit()
        last_timestamp = conn.execute("SELECT * FROM last_timestamp WHERE type='RPG'")
        last_timestamp = last_timestamp.fetchone()[0]

    print(f"Last timestamp for RPG game: {last_timestamp}, current timestamp: {int(round(time.time()))}")
    
    rawdata = f"fields id, game, date; where game.platforms = 6 & date > {last_timestamp} & game.genres = {categories_ids['role-playing-rpg']}; sort date asc; limit 10;"
    print("a")
    r = wrapper.api_request('release_dates', rawdata)

    print("Do this get ran?")
    print("b")
    r = r.decode()
    print("c")
    data = json.loads(r)

The task seems to just stops running at the "do this get ran" mark, and then the entire function start again, even though the loop timer is 120 seconds, so something is causing the loop to reset itself for some reason, the same function runs fine in a python intepreter

mint lynx
#

How long does it take to get to
print("Do this get ran?")
print("b")
I'm assuming your hitting a web API?

bright axle
#

It takes around 2 seconds or so