From d80559e166cd880018810f8f7e6b9bca87dc6bf9 Mon Sep 17 00:00:00 2001 From: Jimmie Hogklint Date: Fri, 1 May 2020 11:27:55 +0200 Subject: [PATCH] Disconnect clients from pool Calling coroutines outside of event loop does not work very well. Adding it to the event loop instead. --- pydle/client.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pydle/client.py b/pydle/client.py index 74a21a2..995d8e6 100644 --- a/pydle/client.py +++ b/pydle/client.py @@ -469,7 +469,7 @@ class ClientPool: """ Remove client from pool. """ self.clients.remove(client) del self.connect_args[client] - client.disconnect() + asyncio.run_coroutine_threadsafe(client.disconnect(expected=True), self.eventloop) def __contains__(self, item): return item in self.clients @@ -491,6 +491,3 @@ class ClientPool: # run the clients self.eventloop.run_forever() - - for client in self.clients: - client.disconnect()