Repository navigation
Untangle Python workers initialization steps - #8516
Conversation
There was a problem hiding this comment.
Superseded by the review of
49e8ebf0.
This review, of 68fabb20
✅ Approved — This is a refactor with no functional change. The initialization order, how imports are proxied and the exported values are all the same as before, and I found no issues.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
import() is still called from the user-bundle module, so INTERNAL modules stay unreachable from Python imports.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
The initialization steps keep their old order inside initPythonOnce(), and the exported values are unchanged.
⚡ Performance: ✅ LGTM
No performance impact.
📝 Documentation: ✅ LGTM
The new comments describe accurately why the import and the base classes are passed in from python-entrypoint.js, and why initPython() can only be called once.
Reviewed commit: 68fabb20
68fabb2 to
49e8ebf
Compare
There was a problem hiding this comment.
✅ Approved — This refactor makes no functional change, and nothing was found to flag. Since the last review, the only change is to doAnImport, which takes the approver's suggestion. The initialization order, how imports are proxied, and the exported values are all the same as before.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
import() is still called from python-entrypoint.js, which is a user-bundle module. Internal modules therefore still can't be imported from Python.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates are needed.
📋 Code Quality: ✅ LGTM
initPython()runs the setup steps in the same order as before.doAnImportstill wraps the result ofimport(name)increateImportProxy.setDoAnImport,createImportProxyandmakeEntrypointClassused to be exported. Nothing uses them as exports any more.defaultExportandpythonEntrypointsare computed with the same logic that used to be inpython-entrypoint.js.- The module-level
initializedguard starts unset in every new isolate.python-entrypoint.jscallsinitPython()once, at the top level.
⚡ Performance: ✅ LGTM
No performance impact. The one-time setup runs in the same order as before, pythonEntrypoints is built once at startup, and the initialized guard only adds a boolean check.
📝 Documentation: ✅ LGTM
The new comments correctly explain:
- why the import function and the base classes are passed in from
python-entrypoint.js; - why
initPython()can only be called once; - when
createImportProxywraps an import.
Reviewed commit: 49e8ebf0
…-init Untangle Python workers initialization steps
Refactors Python workers entrypoint code, without functional change.
python-entrypoint.jsis a user module, used as an entrypoint for Python workers.python-entrypoint-helper.tsis a builtin module, which have an access to internal modules.python-entrypoint.jscallspython-entrypoint-helper.ts.Previously,
python-entrypoint-helper.tswas exporting a few functions to python-entrypoint andpython-entrypointwas calling those functions in a top-level, making the top-level execution steps quite tangled and hard to understand.This changes it as follows:
python-entrypoint-helper.tsexposeinitPython()function only.python-entrypoint.jsnow is just callinginitPython()and pass objects thatpython-entrypoint-helper.tscannot read directly.