Skip to content

[runtime] Support async execution for cross language resources. - #571

Merged
xintongsong merged 2 commits into
apache:mainfrom
wenjin272:cross-async
Apr 7, 2026
Merged

xintongsong merged 2 commits into
apache:mainfrom
wenjin272:cross-async

Conversation

@wenjin272

@wenjin272 wenjin272 commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue: #448

Purpose of change

When invoking a Java method via Pemja from a Python async thread, if that Java method creates objects using reflection, a ClassNotFoundException may occur because the Python async thread lacks the necessary Java environment context.

In Flink agents, this issue occurs when the Python API calls a Java resource that depends on other Java resources in async thread. For example, the python chat model action call chat of a java chat model setup, and the setup will get the correspond chat model connection, which will construct the connection object by reflection.

To resolve this issue, this pr moves the construction of resources from chat/embed method to open, and the open will invoked in flink mailbox thread. Additionally, we have added a check similar to the one for memory: users are now prohibited from calling get_resource outside of a mailbox thread.

This patch depends on alibaba/pemja#95 in pemja. Therefore, we need to wait for the fix versions for Pemja and Flink 1.20, 2.0, 2.1, and 2.2.

Tests

existed e2e test for cross language resources

API

Yes. Add open for Resource

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

@github-actions github-actions Bot added priority/major Default priority of the PR or issue. fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. doc-needed Your PR changes impact docs. labels Mar 17, 2026
@wenjin272
wenjin272 force-pushed the cross-async branch 3 times, most recently from d6497a7 to 632d7b9 Compare March 18, 2026 09:30
@wenjin272

Copy link
Copy Markdown
Contributor Author

After the code review is complete with no issues, I will add the corresponding documentation updates to this PR.

@github-actions github-actions Bot added doc-needed Your PR changes impact docs. and removed doc-needed Your PR changes impact docs. labels Mar 31, 2026

@xintongsong xintongsong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wenjin272 I've left some comments. PTAL. There are also some conflicts that need to be resolved.

Comment thread tools/ut.sh Resolved
@wenjin272
wenjin272 force-pushed the cross-async branch 3 times, most recently from 5426f7d to 3024ef9 Compare April 5, 2026 08:14

@xintongsong xintongsong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@xintongsong
xintongsong merged commit 05ed991 into apache:main Apr 7, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-needed Your PR changes impact docs. fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants