Fixed an issue with sockets

This commit is contained in:
nocturn9x 2020-07-06 20:38:54 +00:00
parent 1676f3149b
commit 0725e8695d
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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):