DeMaking commited on
Commit
b868daf
·
verified ·
1 Parent(s): 9e51418

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +4 -8
bot.py CHANGED
@@ -199,15 +199,11 @@ if __name__ == "__main__":
199
  # Apply nest_asyncio to support nested event loops if required.
200
  nest_asyncio.apply()
201
  try:
202
- loop = asyncio.get_event_loop()
203
  print("in try")
204
- if loop.is_running():
205
- print("in if")
206
- # If an event loop is already running, schedule main() as a task
207
- loop.create_task(main())
208
- else:
209
- print("in else")
210
- loop.run_until_complete(main())
211
  except Exception as e:
212
  logger.error(f"Error in main loop: {e}")
213
  print(f"Error in main loop: {e}")
 
199
  # Apply nest_asyncio to support nested event loops if required.
200
  nest_asyncio.apply()
201
  try:
 
202
  print("in try")
203
+ loop = asyncio.get_event_loop()
204
+ # Schedule the main() task
205
+ loop.create_task(main())
206
+ loop.run_until_complete(main())
 
 
 
207
  except Exception as e:
208
  logger.error(f"Error in main loop: {e}")
209
  print(f"Error in main loop: {e}")