From 0725e8695d154316db29cdca4aafaebff9cca295 Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Mon, 6 Jul 2020 20:38:54 +0000 Subject: [PATCH] Fixed an issue with sockets --- giambio/_core.py | 2 -- giambio/socket.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/giambio/_core.py b/giambio/_core.py index bb02e38..adfc227 100644 --- a/giambio/_core.py +++ b/giambio/_core.py @@ -92,7 +92,6 @@ class AsyncScheduler: self.reschedule_parent(self.current_task) raise # Maybe find a better way to propagate errors? - def create_task(self, coro: types.coroutine): """Spawns a child task""" @@ -129,7 +128,6 @@ class AsyncScheduler: def want_write(self, sock: socket.socket): """Handler for the 'want_write' event, registers the socket inside the selector to perform I/0 multiplexing""" - busy = False try: self.selector.register(sock, EVENT_WRITE, self.current_task) diff --git a/giambio/socket.py b/giambio/socket.py index efdeac3..7f7245d 100644 --- a/giambio/socket.py +++ b/giambio/socket.py @@ -20,6 +20,7 @@ limitations under the License. import socket from .exceptions import ResourceClosed +from ._traps import sleep try: from ssl import SSLWantReadError, SSLWantWriteError WantRead = (BlockingIOError, InterruptedError, SSLWantReadError) @@ -74,6 +75,7 @@ class AsyncSocket(object): async def close(self): """Closes the socket asynchronously""" + await sleep(0) # Give the scheduler the time to unregister the socket first await self.loop.close_sock(self.sock) async def connect(self, addr: tuple):