Remove cleanup

`cleanup` cancels all tasks in the loop, including the main one run by
`run_until_complete`
This commit is contained in:
mhchia
2019-09-09 23:09:33 +08:00
parent a45eb76421
commit bb0da41eda
10 changed files with 9 additions and 65 deletions

View File

@ -1,6 +1,3 @@
import asyncio
from contextlib import suppress
import multiaddr
from libp2p import new_node
@ -17,20 +14,6 @@ async def connect(node1, node2):
await node1.connect(info)
# FIXME: Should be deprecated, since it also kills the main task.
async def cleanup():
pending = asyncio.all_tasks()
for task in pending:
task.cancel()
# Now we should await task to execute it's cancellation.
# Cancelled task raises asyncio.CancelledError that we can suppress:
# NOTE: Changed from `asyncio.CancelledError` to `Exception`, to suppress all exceptions
# including the one in `run_until_complete`.
with suppress(Exception):
await task
async def set_up_nodes_by_transport_opt(transport_opt_list):
nodes_list = []
for transport_opt in transport_opt_list: