Open Martzki opened 2 years ago
That's werid. Seems I shouldn't create a new event_loop in a thread. When I do this, the errors are gone:
diff --git a/11.py b/1.py
index 16145fe..a1e117f 100644
--- a/11.py
+++ b/1.py
@@ -9,8 +9,8 @@ logging.basicConfig(level=logging.DEBUG)
async def h(a):
print('a')
-def w():
- asyncio.set_event_loop(asyncio.new_event_loop())
+def w(loop):
+ asyncio.set_event_loop(loop)
d.init_websocket(h)
d = Driver( options={
@@ -23,7 +23,7 @@ d = Driver( options={
d.login()
-t = threading.Thread(target=w)
+t = threading.Thread(target=w, args=[asyncio.get_event_loop()])
t.start()
try:
I got
To handle signals and to execute subprocesses, the event loop must be run in the main thread.
from event_loop doc so I'll try to use multiprocessing instead :)
Here is my code:
I am running the
Driver.init_websocket()
in another threadw
. When I'm calling theDriver.disconnect()
, the event_loop keep running and finally we got errorERROR:asyncio:Task was destroyed but it is pending!
like this:I'm not good at python so I'm not sure if it's an issue.