-
Notifications
You must be signed in to change notification settings - Fork 98
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
Future: detect blocking calls in methods that return Futures #76
Comments
This may also apply when a method returns other future-like objects: |
BlockHound already detects this Kafka's issue: https://speakerdeck.com/bsideup/geekout-2019-dont-be-homer-simpson-with-your-reactor?slide=116 There is no need to support "methods that return Future" because BlockHound operates on Threads level :) |
Oh. However, someone (in their enterprise app) might still use Futures (e.g. for their do it yourself concurrency). In that case, BlockHound might spot that the app is using an unexpected call sequence. |
Pardon a little Scala code... def myMethod(): Future[Result] = {
try {
val res: Result = rpc()
successful(res)
} catch {
case e: Exception => failed(e)
}
} Code pretty much like this was an inspiration for the checklist item. |
@bsideup even if we are already in a thread pool designed for blocking operations, this may introduce unnecessary delay: imagine we want to parallelize execution of myMethod().thenAcceptBoth(myMethod2(), (res, res2) -> { ... }); This code will unnecessarily wait for the blocking operation in the beginning of |
Motivation
https://twitter.com/leventov/status/1209782345756270592
https://cwiki.apache.org/confluence/display/KAFKA/KIP-286%3A+producer.send%28%29+should+not+block+on+metadata+update
Desired solution
It should print an error or raise an exception if a blocking call is executed from a method that returns Future.
Considered alternatives
Inspect code manually
The text was updated successfully, but these errors were encountered: