-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
[v2.py] ./pants run
implementation can be problematic in the face of application re-execs
#4682
Comments
Can you walk me through an example of the problem? What does this development server do? |
it's a thirdparty development webserver that reloads itself when it detects filesystem changes. looks like it's doing the equivalent of:
but it seems to be losing the |
I've pushed a minimal repro to https://github.com/twitter/pants/tree/kwlzn/4682_repro here's what the repro looks like in this branch:
but note that if you
this points to an issue with the pex composition happening in run vs a monolithic pex in the face of a ~typical application restart. |
just hit this same issue while working on a project related to Jupyter notebook + pex when trying to use in order to spawn kernels (the server-side piece of jupyter execution), we make jupyter aware of the executing pex's environment and point to it with an alternate entrypoint for subprocess launching. this works fine with |
I think this is related to the environment scrubbing in pex here: https://github.com/pantsbuild/pex/blob/6b3fbdf873a9effe3d8371b7a0939f6027e91ac4/pex/pex.py#L52 which seems to be the correct thing to do, lest we leak |
…o metadata (#417) Problem: Pex environments rely on the PEX_PATH environment variable to resolve modules from other pexes when composing them into a single pex. Python scripts that re-execute (like a server listening for fs changes, a Jupyter notebook) throw an ImportError upon re-exec due to environment scrubbing that removes this PEX_PATH information. Solution: Add a --pex-path argument to the pex client and plumb the data through to the pex-info metadata. Resolve pexes to compose into the current pex being built by reading from the new pex_path property of the pex-info metadata. This will ensure a self-contained environment that does not lose context on a python script re-exec. Relates to: pantsbuild/pants#4682
Oops - fixed by pex-tool/pex@5c663c8 and #4969 Just never closed. |
in the v2 python backend, the
run
task implementation now uses PEX_PATH to compose a pex environment at runtime.we had a particular case in our monorepo where a user was attempting to use
./pants run
in conjunction with a development server that would re-exec itself when e.g. files changed on disk. in the v1 backend, this worked fine as everything was self-contained in a singular pex that could be neatly re-executed with it's full environmental context intact. in the v2 backend, this mode of re-execution now breaks with import errors because the PEX_PATH composition context is not self-contained (i.e. after a re-exec, it may be missing the entire sources pex environment).seems like we'll need to figure out a strategy to make self-contained re-execs possible again - and potentially also a flag to enable
run
to run directly from sources vs a composed pex to support the "live development" workflow. cc @benjyw in case he has any ideas on either of these.The text was updated successfully, but these errors were encountered: