Open d0rksh opened 2 years ago
i tried to use prologue but the mySched is never called, its not printing anything
import prologue
import httpclient
import schedules, times, asyncdispatch
scheduler mySched:
every(seconds=5, id="sync tick"):
echo("hello world", now())
proc hello*(ctx: Context) {.async.} =
resp "<h1>Hello, Prologue!</h1>"
proc main()=
asyncCheck mySched.start()
let app = newApp()
app.get("/", hello)
app.run()
when isMainModule:
main()
DEBUG Prologue is serving at http://0.0.0.0:8080
DEBUG Starting 12 threads
I think jester has introduced newSettings
since the nim-schedules doc was written. Since scheduler mySched:
implicitly requires newSettings
from nim-schedules, not one from jester, nim compiler complains.
Re Prologue, I haven't used it. I'll test it out.
I've been fighting with something like this for hours, yesterday. The initial reason being that this example is garbage.
Not even the syntax is correct; notice line 110.
So, after debugging jester
for what seemed like forever, I found the magic line that makes schedules work, even when something else is running mainly:
while true:
stderr.writeLine "Master Thread"
sleep 1_000
try:
asyncdispatch.poll(0) # Must be in a loop, every couple of seconds. Otherwise, scheduler won't work properly.
except ValueError:
continue
@d0rksh This will solve your issue with prologue
.
hii when i try to use nim-schedules with jester it gives the below error
code
error:
ambiguous call; both scheduler.newSettings(appName: string, errorHandler: proc (fut: Future[system.void]){.closure, gcsafe.}) [proc declared in /home/user/.nimble/pkgs/schedules-0.2.0/schedules/scheduler.nim(235, 6)] and jester.newSettings(port: Port, staticDir: string, appName: string, bindAddr: string, reusePort: bool, futureErrorHandler: proc (fut: Future[system.void]){.closure, gcsafe.}) [proc declared in /home/user/.nimble/pkgs/jester-0.5.0/jester.nim(407, 6)] match for: ()