Created
July 29, 2023 22:25
-
-
Save e-dreyer/815aa01b47cb1cb7c92f41bdfff95c66 to your computer and use it in GitHub Desktop.
Async main loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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