Skip to content

Commit

Permalink
Merge pull request #9 from soasme/issue-8
Browse files Browse the repository at this point in the history
Bugfix: the first job schedule should be after startTime.
  • Loading branch information
soasme authored Jul 8, 2021
2 parents 3c4a025 + 6528188 commit bbde032
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/schedules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,18 @@ proc fire*(
if nextRunTime.isNone: break
prev = nextRunTime

let sleepDuration = nextRuntime.get() - now()
let sleepMs = cast[int](sleepDuration.inMilliseconds)
if sleepMs > 0:
await sleepAsync(sleepMs)

if not self.throttler.throttled:
let fut = self.beaterProc()
self.throttler.submit(fut)
asyncCheck fut
else:
debug("\"", self.id, "\" is trottled. Maximum num is ", self.throttler.num, ".")

let sleepDuration = max(initDuration(seconds = 1), nextRunTime.get()-now())
await sleepAsync(cast[int](sleepDuration.inMilliseconds))


type
Expand Down Expand Up @@ -245,7 +248,6 @@ proc parseEvery(call: NimNode): tuple[
startTime: NimNode,
endTime: NimNode,
] =
# echo(call.treeRepr)
var async: bool = false
var id = newLit("")
var throttleNum = newLit(1)
Expand Down

0 comments on commit bbde032

Please sign in to comment.