I am having a thread which calls asyncio loops, however this causes the mentioned exception:
RuntimeError: There is no current event loop in thread 'Thread-1'.
This question: RuntimeError: There is no current event loop in thread in async + apscheduler came across the same problem, however they refered to a scheduler which I do not have.
My code is the following:
def worker(ws):
      l1 = asyncio.get_event_loop()
      l1.run_until_complete(ws.start())  
      l2 = asyncio.get_event_loop()
      l2.run_forever()
if __name__ == '__main__':
    ws = Server()
    p = threading.Thread(target=worker,args=(ws,))
    p.start()
    while True:
        try:
            #...do sth
        except KeyboardInterrupt:
            p.join()
            exit() 
 
     
     
     
    