mirror of https://github.com/nocturn9x/giambio.git
Fixed an issue with sockets
This commit is contained in:
parent
1676f3149b
commit
0725e8695d
|
@ -92,7 +92,6 @@ class AsyncScheduler:
|
||||||
self.reschedule_parent(self.current_task)
|
self.reschedule_parent(self.current_task)
|
||||||
raise # Maybe find a better way to propagate errors?
|
raise # Maybe find a better way to propagate errors?
|
||||||
|
|
||||||
|
|
||||||
def create_task(self, coro: types.coroutine):
|
def create_task(self, coro: types.coroutine):
|
||||||
"""Spawns a child task"""
|
"""Spawns a child task"""
|
||||||
|
|
||||||
|
@ -129,7 +128,6 @@ class AsyncScheduler:
|
||||||
def want_write(self, sock: socket.socket):
|
def want_write(self, sock: socket.socket):
|
||||||
"""Handler for the 'want_write' event, registers the socket inside the selector to perform I/0 multiplexing"""
|
"""Handler for the 'want_write' event, registers the socket inside the selector to perform I/0 multiplexing"""
|
||||||
|
|
||||||
|
|
||||||
busy = False
|
busy = False
|
||||||
try:
|
try:
|
||||||
self.selector.register(sock, EVENT_WRITE, self.current_task)
|
self.selector.register(sock, EVENT_WRITE, self.current_task)
|
||||||
|
|
|
@ -20,6 +20,7 @@ limitations under the License.
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
from .exceptions import ResourceClosed
|
from .exceptions import ResourceClosed
|
||||||
|
from ._traps import sleep
|
||||||
try:
|
try:
|
||||||
from ssl import SSLWantReadError, SSLWantWriteError
|
from ssl import SSLWantReadError, SSLWantWriteError
|
||||||
WantRead = (BlockingIOError, InterruptedError, SSLWantReadError)
|
WantRead = (BlockingIOError, InterruptedError, SSLWantReadError)
|
||||||
|
@ -74,6 +75,7 @@ class AsyncSocket(object):
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""Closes the socket asynchronously"""
|
"""Closes the socket asynchronously"""
|
||||||
|
|
||||||
|
await sleep(0) # Give the scheduler the time to unregister the socket first
|
||||||
await self.loop.close_sock(self.sock)
|
await self.loop.close_sock(self.sock)
|
||||||
|
|
||||||
async def connect(self, addr: tuple):
|
async def connect(self, addr: tuple):
|
||||||
|
|
Loading…
Reference in New Issue