mirror of https://github.com/nocturn9x/giambio.git
Minor changes
This commit is contained in:
parent
63b90dcfb0
commit
91b2cfb9da
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
2
test.py
2
test.py
|
@ -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!
|
||||
|
|
Loading…
Reference in New Issue