Merge pull request #1051 from status-im/shutdown

Eth2Node.stop(): 5s timeout
This commit is contained in:
Ștefan Talpalaru 2020-05-21 02:25:34 +02:00 committed by GitHub
commit 0f0833a018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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