Skip to content

Conversation

@dianfu
Copy link
Contributor

@dianfu dianfu commented Nov 3, 2025

What is the purpose of the change

  • This pull request optimizes AsyncFunction interface to remove ResultFuture. *

Brief change log

  • *Removes ResultFuture from the signature of AsyncFunction *

Verifying this change

This change is already covered by existing tests in test_async_function.py*.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Nov 3, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@dianfu dianfu force-pushed the optimize_async_function branch from 3fbf8f5 to e7cbc94 Compare November 3, 2025 07:57


class ResultFuture(Generic[OUT]):
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should deprecate the old API and introduce this, in this way exiting applications will not break and the older API version can be managed out. This is less a consideration for master - but is a consideration for the backports.

Copy link
Contributor Author

@dianfu dianfu Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidradl Good point! This is introduced in Flink 2.2 and so there is no backward compatibility issues (I'd like to make sure this is merged into Flink 2.2).

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Nov 3, 2025
Copy link
Contributor

@bgeng777 bgeng777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is great as it is more pythonis. My only concern is that the exception propagation is somehow different.

# complete with empty result, so that we remove timer and move ahead processing
self._process_results([])

raise RuntimeError("The 'result_future' of AsyncFunction should be completed with "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we get rid of 'result_future' in the AsyncFunction, we may change the error description here as well when users return non-iterable result

async def async_invoke(self, value: Row):
await asyncio.sleep(2)
result_future.complete([value[0] + value[1]])
return [value[0] + value[1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modify the test a little to return None and I find that the test can run without throwing The 'result_future' of AsyncFunction should be completed with ... exception.
Is that expected?

@dianfu dianfu force-pushed the optimize_async_function branch from 13de53d to fdedefc Compare November 4, 2025 12:29
Copy link
Contributor

@bgeng777 bgeng777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great work, LGTM!

@dianfu dianfu merged commit 8688dce into apache:master Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants