Skip to content

Instantly share code, notes, and snippets.

@e-dreyer
Created July 29, 2023 22:25
Show Gist options
  • Save e-dreyer/815aa01b47cb1cb7c92f41bdfff95c66 to your computer and use it in GitHub Desktop.
Save e-dreyer/815aa01b47cb1cb7c92f41bdfff95c66 to your computer and use it in GitHub Desktop.
Async main loop
if __name__ == "__main__":
config = ConfigAccessor("config.yml")
credentials = ConfigAccessor("credentials.yml")
bot = MyBot(credentials=credentials, config=config)
async def main_loop():
while True:
loop = asyncio.get_event_loop()
await asyncio.gather(
loop.run_in_executor(None, bot.run),
loop.run_in_executor(None, bot.processPythonDiscusPendingPosts)
)
await asyncio.sleep(10)
async def main_loop_2():
while True:
await asyncio.gather(bot.fetchLatestPosts())
await asyncio.sleep(120)
async def main():
await asyncio.gather(main_loop(), main_loop_2())
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment