RuntimeError: This event loop is already running, while connecting 3 websocket connections
Looks like, you are already running 3 WebSocket streams(maximum allowed connections). You need to stop all previous active connections and then initiate the new ones. Also, make sure you are not using any daemon/background process/threads in your current program to initiate new connections from the same.
Thank you @rakeshr for your reply, I am using python programming with Django framework, Whenever I run the server for the first time everything works fine, but for some reason if the server is restarted or if I restart it then I get this error. Where I created a class for the connection code and trying to create 3 instance of that class. like this
with ThreadPoolExecutor(max_workers=3) as executor: try: executor.submit(kws1.connect, True) executor.submit(kws2.connect, True) executor.submit(kws3.connect, True) except: pass
@rakeshr sir, I can try any of the solution in my code but I am really stucked where I think I can't do anything. Means I am getting the error just after I run kws.connect(threaded=True), where I commented two more connection instances.
@rakeshr sir, Still I didn't get you, The thread you share I gone through that but where I should apply it when I didn't have any code to create async calls, are you saying that I have to call kws1.connect with await call ?
Whenever I run the server for the first time everything works fine, but for some reason if the server is restarted or if I restart it then I get this error.
Where I created a class for the connection code and trying to create 3 instance of that class.
like this
with ThreadPoolExecutor(max_workers=3) as executor:
try:
executor.submit(kws1.connect, True)
executor.submit(kws2.connect, True)
executor.submit(kws3.connect, True)
except:
pass
Means I am getting the error just after I run kws.connect(threaded=True), where I commented two more connection instances.
kws1.connect(threaded=True)
print('kws connected.....................................')
Here I attached the log file maybe this file will help.
are you saying that I have to call kws1.connect with await call ?