Skip to content
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

fix(python): leftover jsii-kernel-* directories in TMPDIR #2100

Merged
merged 3 commits into from
Oct 14, 2020

Conversation

RomainMuller
Copy link
Contributor

The Python runtime did not properly signal shutdown to the node
process hosting the jsii kernel, causing it to be abruptly killed on
Python interpreter exit. This means the jsii kernel's own clean-up
code was not allowed to run.

This adds an atexit hook which will properly close the node process'
STDIN file descriptor, effectively signaling it should shut down. This
then gives the process 5 seconds to clean up after itself and finish
before sending it SIGTERM (at which point it is given 5 seconds to
terminate after which it will be terminated).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The Python runtime did not properly signal shutdown to the `node`
process hosting the *jsii kernel*, causing it to be abruptly killed on
Python interpreter exit. This means the *jsii kernel*'s own clean-up
code was not allowed to run.

This adds an `atexit` hook which will properly close the `node` process'
`STDIN` file descriptor, effectively signaling it should shut down. This
then gives the process 5 seconds to clean up after itself and finish
before sending it `SIGTERM` (at which point it is given 5 seconds to
terminate after which it will be terminated).
@RomainMuller RomainMuller added bug This issue is a bug. language/python Related to Python bindings effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` p2 labels Oct 9, 2020
@RomainMuller RomainMuller added this to the October Release milestone Oct 9, 2020
@RomainMuller RomainMuller requested a review from a team October 9, 2020 13:07
@RomainMuller RomainMuller self-assigned this Oct 9, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 9, 2020
@RomainMuller
Copy link
Contributor Author

@all-contributors add @edsenabr for bug since he's the one who mentioned this one to me!

@allcontributors
Copy link
Contributor

@RomainMuller

I've put up a pull request to add @edsenabr! 🎉

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 7d1fd14
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@RomainMuller RomainMuller merged commit c119994 into master Oct 14, 2020
@RomainMuller RomainMuller deleted the rmuller/python-cleanup branch October 14, 2020 10:18
RomainMuller added a commit that referenced this pull request Nov 12, 2020
This change adds shutdown hook registrations in the .NET and Java
runtimes so that the `node` process hosting the JSII runtime is
gracefully terminated upon program end. This allows any "on exit" hooks
registered in the JavaScript process to properly run when the host
program ends. This is similar to what was done in #2100 for Python.

Additionally, removed the code that surrounded handling of the `STDERR`
stream from the Kernel process: there is no need to `PIPE` it, and
simply inheriting it (i.e: subprocess `STDERR` is the same stream as the
parent's) results in a more intuitive behavior, as `STDERR` output from
child processes surfaces "immediately" even if the parent process
somehow cannot forward it anymore (e.g: if it crashed or deadlocked).
This also means the `STDERR` forwarding thread is no longer needed.
mergify bot pushed a commit that referenced this pull request Nov 16, 2020
This change adds shutdown hook registrations in the .NET and Java
runtimes so that the `node` process hosting the JSII runtime is
gracefully terminated upon program end. This allows any "on exit" hooks
registered in the JavaScript process to properly run when the host
program ends. This is similar to what was done in #2100 for Python.

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort language/python Related to Python bindings module/runtime Issues affecting the `jsii-runtime` p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants