Skip to content

Commit

Permalink
Fix event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Benyamin Ginzburg committed Aug 20, 2024
1 parent 89bbcb2 commit ce3c19e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bus_bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ async def on_start(bot: Bot):
await bot.set_my_commands(DEFAULT_COMMANDS)


async def main():
async def async_main(dp: Dispatcher, bot: Bot):
await bot.delete_webhook()
await dp.start_polling(bot, allowed_updates=ALLOWED_UPDATES)


def main():
motor_client = AsyncIOMotorClient(env.DB_URL)
storage = MongoStorage(client=motor_client, db_name=env.DB_NAME, collection_name=env.DB_COLLECTION_NAME)
db_repo = DbRepo(motor_client)
Expand Down Expand Up @@ -85,7 +89,7 @@ async def main():

web.run_app(app, host=env.WEBAPP_HOST, port=env.WEBAPP_PORT)
else:
await dp.start_polling(bot, allowed_updates=ALLOWED_UPDATES)
asyncio.run(async_main(dp, bot))


if __name__ == '__main__':
Expand All @@ -94,4 +98,4 @@ async def main():

asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())

asyncio.run(main())
main()

0 comments on commit ce3c19e

Please sign in to comment.