-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix delivery & error callbacks and polling #13
Conversation
document callbacks and seeking add test for error callback
I added this as an inline comment previously, but I'm not sure you can see it. Sorry if I'm repeating it. @async while polling
kafka_poll(rk, 0)
sleep(1)
end
# run a loop in a separate task
# sleep() makes a scheduler to switch to other tasks
@async while true
println("working")
sleep(1)
end
# run a blocking loop in the current task
for i=1:1_000_000_000
rand(1000)
end While the current task makes the computation, the the additional task doesn't print anything. I never had a chance to try it, but (Note that my previous code using the |
Though, using |
@attdona Thanks for the great point about exceptions in #14. It led me to try and catch an error thrown in the thread, which I wasn't able to do (so far). Catching errors from threads doesn't seem possible at the moment (!) so I'm reverting this to an @async Task. At least it will irregularly poll, which should be fine as long as the |
… exception handling
@dfdx I did find a way to catch the error from the thread like so:
ie. a Task to wait for the thread to complete. But to catch the exception and crash the app, the application would also have to use an |
Yeah, until we run into a specific issue, I believe single-threaded version is the safest one. Thank you for driving this change! |
I think now it is more difficult to have an uncatchable exception, but this is not completely safe ... For what I know @async function and timer callback suffer the same problem: when they terminate the internal julia "kernel" does keep them around in a "NOT RUNNABLE" state: if they are the last active task (the last task run by the scheduler) the SIGINT is delivered to such not runnable task and this cause a You should reproduce this issue with this snippet. It is a contrived example just for expose the problem.
result (Ctrl-C after waiting a second after the msg = nothing trace):
|
But if we start the polling in the Also note that due to As a side note, here's the relevant issue in the Julia repo: JuliaLang/julia#34184 |
I Agree, I think a To avoid the problem For a consumer app I'll reconsidered the idea of @kschzt of using Since the consumer will pass most of the time polling for messages I suppose that the reason why exists |
|
seek()
produce()