I have a while True
statement, and inside that I have a for loop
.
I'd like to run the function first_start
only once for each app
.
I already tried the query below, but it don't seems to work:
while True:
do_first_start = True
for app in applications:
if do_first_start:
# Reloading page before start the bot
await asyncio.create_task(first_start(app_name=bot))
do_first_start = False
I also took a look on this question from @Marcus Ottosson, but I couldn't make it work as well.
My script:
while True:
do_first_start = True
for app in applications:
bot = app.split(':')[1].strip()
print('Going to bot: ' + str(bot))
app = Desktop(backend="uia").windows(title=app)[0]
app.set_focus()
if do_first_start:
# Reloading page before start the bot
await asyncio.create_task(first_start(app_name=bot))
do_first_start = False
# Steps of this bot:
# - Connect Wallet
await asyncio.create_task(connect_wallet(app_name=bot))
# - Login
await asyncio.create_task(login_metamask(app_name=bot))
# - Treasure Hunt
await asyncio.create_task(treasure_hunt_game(refresh_only=True, app_name=bot))
# - New map
await asyncio.create_task(new_map(app_name=bot))
# - Check for errors
await asyncio.create_task(skip_error_on_game(app_name=bot))
What would be the best way to run the function only once in this case?