0
if __name__ =='__main__': 
  bot.run()
  web.run_app(app, port=5000)

I am trying to run these 2 simultaneously, however, one is blocking the other. Any help would be appreciated. Thanks

cconsta1
  • 737
  • 1
  • 6
  • 20

1 Answers1

1

If they are both synchronous (no async or await) then you can use

import threading

threading.Thread(target=bot.run).start()
# or threading.Thread(target=web.run_app, args=(app,), kwargs={"port": 5000"}

and then use threading.Lock for database operations (https://docs.python.org/3/library/threading.html#threading.Lock).

If one is asynchronous, then look at this.