Minor changes

This commit is contained in:
nocturn9x 2020-03-21 09:59:59 +00:00
parent 63b90dcfb0
commit 91b2cfb9da
3 changed files with 8 additions and 1 deletions

View File

@ -79,6 +79,8 @@ class EventLoop:
return task
def start(self, coroutine: types.coroutine, *args, **kwargs):
"""Starts the eventloop"""
self.spawn(coroutine(*args, **kwargs))
self.loop()
@ -95,6 +97,8 @@ class EventLoop:
self.selector.register(sock, EVENT_WRITE, self.running)
def wrap_socket(self, sock):
"""Wraps a standard socket into an AsyncSocket"""
return AsyncSocket(sock, self)
async def read_sock(self, sock: socket.socket, buffer: int):

View File

@ -51,3 +51,6 @@ class AsyncSocket(object):
def __repr__(self):
return f"giambio.socket.AsyncSocket({self.sock}, {self.loop})"
def __getitem__(self, item):
return self.sock.__getitem__(item)

View File

@ -21,7 +21,7 @@ async def make_srv(address: tuple):
await giambio.sleep(2)
logging.info("Done!")
while True:
conn, addr = await asock.accept()
conn, addr = await asock.accept() # TODO: Figure out why this I/O operation actually works while other don't
logging.info(f"{addr} connected")
task = loop.spawn(echo_server(conn, addr))
# await task.cancel() # Cancel task!