Skip to content

Commit 6fff2b7

Browse files
authored
docs: add region tag for sigterm handler (GoogleCloudPlatform#5527)
## Description Fixes #<ISSUE-NUMBER> Note: It's a good idea to open an issue first for discussion. ## Checklist - [ ] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md) - [ ] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#readme-file) - [ ] **Tests** pass: `nox -s py-3.6` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones) - [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones) - [ ] Please **merge** this PR for me once it is approved. - [ ] This sample adds a new sample directory, and I updated the [CODEOWNERS file](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/.github/CODEOWNERS) with the codeowners for this sample
1 parent 052e148 commit 6fff2b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

run/idp-sql/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def save_vote() -> Response:
8989

9090

9191
# https://cloud.google.com/blog/topics/developers-practitioners/graceful-shutdowns-cloud-run-deep-dive
92+
# [START cloudrun_sigterm_handler]
9293
def shutdown_handler(signal: int, frame: FrameType) -> None:
9394
logger.info("Signal received, safely shutting down.")
9495
database.shutdown()
@@ -97,11 +98,15 @@ def shutdown_handler(signal: int, frame: FrameType) -> None:
9798
sys.exit(0)
9899

99100

101+
# [END cloudrun_sigterm_handler]
102+
100103
if __name__ == "__main__":
101104
# handles Ctrl-C locally
102105
signal.signal(signal.SIGINT, shutdown_handler)
103106

104107
app.run(host="127.0.0.1", port=8080, debug=True)
105108
else:
106109
# handles Cloud Run container termination
110+
# [START cloudrun_sigterm_handler]
107111
signal.signal(signal.SIGTERM, shutdown_handler)
112+
# [END cloudrun_sigterm_handler]

0 commit comments

Comments
 (0)