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
feat: make publish futures compatible with concurrent.futures.as_completed()
#374
Conversation
@pradn PTAL, if you have time. It's true that the solution uses Alternatively, we could provide our own After reading the standard library implementation, the first approach actually seemed more favourable (IMHO). |
I can take a look later this week or early next week. :) |
The futures implementation is adjusted to work well with the built-in function with the same name in `concurrent.futures` package.
The overriden method is exactly the same as the base method, only it's docstring is different - no need to keep the code when super() achieves the same.
I took a first pass - looks reasonable. We need to check with Kamal if depending on the internals of a library class like this is fine. It seems to be helpful enough to the user to warrant this, but I wonder if so few are going to use this it might not be worth it. |
Using IIRC the feature request has been confirmed (and Node is adding something similar, too), but I agree we should discuss the approach in this PR - I'll add it to the agenda. |
Looks good to me. It seems like we have consensus with the rest of the team, so perhaps simply ask for confirmation before merging? |
That's the plan. And we might also borrow @jimfulton to have a say on using those implementation details, as he's been around Python ... probably since the fall of the Berlin Wall. 😆 (which might actually not even be far from the truth) |
Decided to also try swapping the futures with std lib's implementation first
After an offline discussion, we think relying on implementation details is not desirable, and the approach highest on the wish list is to swap the current implementation in the library with futures from The public interface is already compatible, but we need to see if that would break Pub/Sub Lite, and also determine the reason why the original authors decided to use their own implementation. @dpcollins-google Does the Pub/Sub Lite client use any internals of the Futures, or just their public interface? Would replacing the futures with the implementation from |
Closing in favor of #397. We prefer less code and don't want to rely on the implementation details of |
Closes #368.
After studying the as_completed() code from the standard library, it actually seemed easier to modify our futures implementation, as opposed to writing our own
as_completed()
logic, which would still require changes to the Future, too (think: locking and notifying).The drawback of course is relying on implementation details from
concurrent.futures
, but good tests should help us here. Let's discuss this drawback here.Current approach pros:
as_completed()
logic.api-core
.Current approach cons:
concurrent.futures
implementation details, although tests should help here. In addition, the standard lib's implementation seems very stable, and changes infrequent (blame) - the key implementation details are more than 10 years old.PR checklist: