mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-07 15:13:08 +00:00
fix: propagate callback cancellation (#1400)
This commit is contained in:
parent
3203dfba41
commit
1a7cf2d335
@ -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
|
||||
|
||||
@ -21,11 +21,11 @@ asyncchecksuite "Timer":
|
||||
var numbersState = 0
|
||||
var lettersState = 'a'
|
||||
|
||||
proc numbersCallback(): Future[void] {.async: (raises: []).} =
|
||||
proc numbersCallback(): Future[void] {.async: (raises: [CancelledError]).} =
|
||||
output &= $numbersState
|
||||
inc numbersState
|
||||
|
||||
proc lettersCallback(): Future[void] {.async: (raises: []).} =
|
||||
proc lettersCallback(): Future[void] {.async: (raises: [CancelledError]).} =
|
||||
output &= $lettersState
|
||||
inc lettersState
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user