-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Driver.disconnect can't end the event_loop gracefully when running in a thread #113
Comments
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
from event_loop doc so I'll try to use multiprocessing instead :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is my code:
I am running the
Driver.init_websocket()
in another threadw
.When I'm calling the
Driver.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.
The text was updated successfully, but these errors were encountered: