mirror of https://github.com/nocturn9x/giambio.git
Fixed cancelling task, need to figure out how to handle CancelledError properly
This commit is contained in:
parent
61503a44db
commit
d06813cd73
|
@ -29,6 +29,12 @@ class Task:
|
|||
def __repr__(self):
|
||||
return f"<giambio.core.Task({self.coroutine}, {self.status}, {self.joined})"
|
||||
|
||||
async def cancel(self):
|
||||
return await cancel(self)
|
||||
|
||||
async def join(self):
|
||||
return await join(self)
|
||||
|
||||
|
||||
class EventLoop:
|
||||
|
||||
|
|
5
test.py
5
test.py
|
@ -23,7 +23,8 @@ async def make_srv(address: tuple):
|
|||
while True:
|
||||
conn, addr = await asock.accept()
|
||||
logging.info(f"{addr} connected")
|
||||
loop.spawn(echo_server(conn, addr))
|
||||
task = loop.spawn(echo_server(conn, addr))
|
||||
await task.cancel()
|
||||
|
||||
|
||||
async def echo_server(sock: AsyncSocket, addr: tuple):
|
||||
|
@ -42,4 +43,4 @@ async def echo_server(sock: AsyncSocket, addr: tuple):
|
|||
logging.info(f"Connection from {addr} closed")
|
||||
|
||||
|
||||
loop.start(make_srv, ('', 1500))
|
||||
loop.start(make_srv, ('', 1501))
|
||||
|
|
Loading…
Reference in New Issue