mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Remove cleanup
`cleanup` cancels all tasks in the loop, including the main one run by `run_until_complete`
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user