Eth2Node.stop(): 5s timeout

This commit is contained in:
Ștefan Talpalaru 2020-05-21 00:05:10 +02:00
parent e4173860f0
commit b2193f1b8f
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
1 changed files with 8 additions and 5 deletions

View File

@ -720,11 +720,14 @@ proc start*(node: Eth2Node) {.async.} =
traceAsyncErrors node.discoveryLoop
proc stop*(node: Eth2Node) {.async.} =
# ignore errors in futures, since we're shutting down
await allFutures(@[
node.discovery.closeWait(),
node.switch.stop(),
])
# Ignore errors in futures, since we're shutting down.
# Use a timer to avoid hangups.
discard await one(sleepAsync(5.seconds),
allFutures(@[
node.discovery.closeWait(),
node.switch.stop(),
])
)
proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer =
new result