'How to run asyncio scheduler for each sequence in a loop?
I have a job scheduler already working as script below, and also a cycle implemented to run a couple of functions for each app. However, as soon as the scheduler hits the proper time, it runs only in the available app.
Scheduling job:
scheduler.add_job(refresh_hereoes_positions, 'interval', seconds=(refresh_heroes_time*60), id='1', name='refresh_hereoes_positions', misfire_grace_time=180)
Loop:
bots = []
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()
await asyncio.create_task(first_start(app_name=bot))
bots.append((app, bot))
# Cycle through the bots in one loop rather than restarting
# the loop in an infinite loop.
for app, bot in cycle(bots):
print('Going to bot: ' + str(bot))
app.set_focus()
await asyncio.create_task(connect_wallet(app_name=bot))
await asyncio.create_task(login_metamask(app_name=bot))
await asyncio.create_task(treasure_hunt_game(refresh_only=True, app_name=bot))
await asyncio.create_task(new_map(app_name=bot))
await asyncio.create_task(skip_error_on_game(app_name=bot))
How can I run the job for each app in the cycle when triggered?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
