[runtime][python] Release per-action Pemja objects - #1049
Draft
joeyutong wants to merge 2 commits into
Draft
Conversation
Close action-scoped PyObject handles after interpreter ownership is established and remove completed awaitables from interpreter globals. Generated-by: Codex (GPT-5) Co-Authored-By: Claude Code <[email protected]> AI-Model: gpt-5 AI-Contributed/Feature: 37/37 AI-Contributed/UT: 155/155
Return only the awaitable completion state across Pemja because Action yielded and returned values are not consumed by the runtime. Co-Authored-By: Claude Code <[email protected]> AI-Model: gpt-5 AI-Contributed/Feature: 29/29 AI-Contributed/UT: 17/17
joeyutong
force-pushed
the
codex/fix-pemja-action-references
branch
from
August 26, 2026 09:08
fb3666e to
2114dc0
Compare
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue: #1048
Purpose of change
PythonActionExecutorrepeatedly creates Java-side PemjaPyObjecthandles while a Python Action is running. Those handles own native Python references and were previously dropped without callingclose().This change:
interpreter.set(...);interpreter.get(...)poll;The last point avoids a recursive ownership problem: an Action output may contain arbitrary nested Python objects, while Java never consumes the output. Actions communicate with the runtime through emitted Events, so the narrow boundary is a boolean completion state.
This is complementary to #944: that PR handles executor-lifetime objects during attempt cleanup, while this PR handles objects created repeatedly during the lifetime of an open executor.
Tests
PythonActionExecutorTest: 11 passed, covering synchronous completion, async storage, Action failure,setfailure, pending/completed polling, and polling failure.test_function.py: 27 passed, including yielded and returned values being reduced to completion state../tools/lint.sh -c: passed for Python lint and all Java Spotless modules.API
No user-facing API changes.
PythonActionExecutorandcall_python_awaitableare internal runtime bridge helpers. The helper now returnsboolrather than(bool, output)because the output was not consumed.PyObject.close()failures continue through the existingActionTask.invoke(...) throws Exceptionpath.Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)