-
Notifications
You must be signed in to change notification settings - Fork 534
Document if Publisher.subscribe is allowed to block #393
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
Comments
@guenhter Did your publisher pass the TCK? |
I think it is unavoidable to have blocking code inside Flowable.fromCallable(() -> {
Thread.sleep(1000);
return 1;
})
.subscribeOn(Schedulers.io())
.subscribe(System.out::println); The main use case is to free up the main thread. You can inline the two so your The TCK can't and doesn't detect if your |
@akarnokd I guess it depends on the definition of "blocking" used. I think it would be surprising to users if they had to assume/do defensive backgrounding of EDIT: The TCK comment was to make sure that all the other bits and pieces are already verified. |
It happens all the time on Android with network or file resources being streamed. Most underlying components use blocking calls (i.e., FileInputStream.read() type of blocking). |
@akarnokd Well, technically referencing new Class causes it to be loaded, which could be a URLClassLoader which could technically block forever. I'm just saying that the general case one should assume that calling |
@guenhter Thanks for pointing out an omission: for |
@rkuhn ømq was just an example. I guess it should be seen more general. If e.g. we have a
|
@guenhter Please read the spec in full: that example code violates many of the Reactive Streams rules, including not respecting back-pressure. If creating a certain Socket is a blocking operation, then it would be prudent to not create the Socket in |
I think if it comes to amending the spec, this expectation should be listed as RxJava users face this often and there are two practices suggested to them: 1) specify in the method javadoc returning a |
@viktorklang I think there is a good point to this issue that needs to be addressed: we have not documented appropriately what the expectations for |
@rkuhn Yes, I agree. Adding an advisory Responsivity clause is both properly backwards compatible, as well as guiding implementations as to what the desired properties should be. |
@akarnokd Switching it to a MUST would be backwards incompatible, a SHOULD or RECOMMENDED might be more appropriate. |
Oops, I accidentally pressed the lovely "Close and comment". |
@viktorklang I'm glad to hear it. |
In |
@guenhter Yep, a sync Publisher would be great to add to the examples! |
Wow! This was fast. Thanks. |
Merged! |
The example is there, but I think the specification changes are missing? I spent some considerable time today trying to figure out if |
Hi,
I'm using reactive-streams and wrote a
Publisher
for ZeroMq.One of the first things is stumbled over was, if the method
Publisher.subscribe(...)
must return and emit the results async, or if the method can block.I looked up the javadoc of the method, but it isn't documented. Would be great to make a statement what is expected by that method.
The text was updated successfully, but these errors were encountered: