Eth2Node.stop(): trace msg on timeout
This commit is contained in:
parent
c0daeb8432
commit
273a912ae0
|
@ -1,6 +1,6 @@
|
||||||
import
|
import
|
||||||
# Std lib
|
# Std lib
|
||||||
typetraits, strutils, os, random, algorithm,
|
typetraits, strutils, os, random, algorithm, sequtils,
|
||||||
options as stdOptions, net as stdNet,
|
options as stdOptions, net as stdNet,
|
||||||
|
|
||||||
# Status libs
|
# Status libs
|
||||||
|
@ -738,14 +738,17 @@ proc start*(node: Eth2Node) {.async.} =
|
||||||
traceAsyncErrors node.discoveryLoop
|
traceAsyncErrors node.discoveryLoop
|
||||||
|
|
||||||
proc stop*(node: Eth2Node) {.async.} =
|
proc stop*(node: Eth2Node) {.async.} =
|
||||||
# Ignore errors in futures, since we're shutting down.
|
# Ignore errors in futures, since we're shutting down (but log them on the
|
||||||
# Use a timer to avoid hangups.
|
# TRACE level, if a timeout is reached).
|
||||||
discard await one(sleepAsync(5.seconds),
|
let
|
||||||
allFutures(@[
|
waitedFutures = @[
|
||||||
node.discovery.closeWait(),
|
node.discovery.closeWait(),
|
||||||
node.switch.stop(),
|
node.switch.stop(),
|
||||||
])
|
]
|
||||||
)
|
timeout = 5.seconds
|
||||||
|
completed = await withTimeout(allFutures(waitedFutures), timeout)
|
||||||
|
if not completed:
|
||||||
|
trace "Eth2Node.stop(): timeout reached", timeout, futureErrors = waitedFutures.filterIt(it.error != nil).mapIt(it.error.msg)
|
||||||
|
|
||||||
proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer =
|
proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer =
|
||||||
new result
|
new result
|
||||||
|
|
Loading…
Reference in New Issue