pulumi/sdk/python/cmd
Abhinav Gupta 2d3a1ecc3e
plugin(go, node, py): Exit cleanly on interrupt (#13809)
This changes the language plugins for Go, Node, and Python
to watch for the os.Interrupt signal (SIGINT on Unix, CTRL_BREAK on
Windows)
that the plugin lifetime manager sends (per #13795)
and exit cleanly on receiving the signal.

This is a no-op for users.
An immediate effect it'll have for us is that
we'll begin seeing test coverage data come out of these binaries.

A similar change is necessary in other language plugin binaries.
I did not touch uses of rpcutil.ServeWithOptions outside `main` packages
because whether a signal handler should be installed there or not
requires more knowledge of individual cases.

Note that this uses [signal.NotifyContext][1].
Calling the returned `cancel()` function removes the signal handler.
This is desirable so that if a user sends the signal again
(e.g., presses Ctrl-C again), we don't capture it
and let the OS kill the process.

  [1]: https://pkg.go.dev/os/signal#NotifyContext

Refs #9780
2023-08-29 15:42:31 +00:00
..
pulumi-language-python plugin(go, node, py): Exit cleanly on interrupt (#13809) 2023-08-29 15:42:31 +00:00
pulumi-language-python-exec [sdk/python] Fix missing program detection on python 11 2023-03-22 07:23:46 -07:00