mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-03-07 12:53:34 +00:00
fix: propagate callback cancellation so timer does not get stuck during stop
This commit is contained in:
parent
7c3894da54
commit
444a5bff7a
@ -100,12 +100,13 @@ proc runBlockCheck(
|
||||
trace "Cycle completed"
|
||||
|
||||
proc start*(self: BlockMaintainer) =
|
||||
proc onTimer(): Future[void] {.async: (raises: []).} =
|
||||
proc onTimer(): Future[void] {.async: (raises: [CancelledError]).} =
|
||||
try:
|
||||
await self.runBlockCheck()
|
||||
except CancelledError as err:
|
||||
trace "Running block check in block maintenance timer callback cancelled: ",
|
||||
err = err.msg
|
||||
raise err
|
||||
|
||||
self.timer.start(onTimer, self.interval)
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ import pkg/chronos
|
||||
import ../logutils
|
||||
|
||||
type
|
||||
TimerCallback* = proc(): Future[void] {.async: (raises: []).}
|
||||
TimerCallback* = proc(): Future[void] {.async: (raises: [CancelledError]).}
|
||||
Timer* = ref object of RootObj
|
||||
callback: TimerCallback
|
||||
interval: Duration
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user