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

[BEAM-10603] Gracefully shutdown the channel reader in the test_stream_impl #12701

Merged
merged 2 commits into from
Sep 2, 2020

Conversation

rohdesamuel
Copy link
Contributor

Change-Id: I5fac037a7dcc141ff9d0ff8058fa3de993626c15

In the case that the kernel is interrupted we want to gracefully shutdown the grpc streaming request from the TestStream. Otherwsie, this throws an esoteric exception.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status --- Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace
Non-portable Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status
Portable --- Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

Change-Id: I5fac037a7dcc141ff9d0ff8058fa3de993626c15
@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #12701 into master will decrease coverage by 0.20%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12701      +/-   ##
==========================================
- Coverage   40.30%   40.09%   -0.21%     
==========================================
  Files         451      455       +4     
  Lines       53168    54026     +858     
==========================================
+ Hits        21429    21663     +234     
- Misses      31739    32363     +624     
Impacted Files Coverage Δ
...hon/apache_beam/runners/direct/test_stream_impl.py 41.17% <0.00%> (-1.58%) ⬇️
...ache_beam/runners/interactive/recording_manager.py 29.60% <0.00%> (-0.98%) ⬇️
.../runners/portability/fn_api_runner/translations.py 14.00% <0.00%> (-0.63%) ⬇️
sdks/python/apache_beam/io/filesystems.py 57.50% <0.00%> (-0.26%) ⬇️
...beam/runners/interactive/background_caching_job.py 25.00% <0.00%> (-0.25%) ⬇️
sdks/python/apache_beam/transforms/environments.py 52.42% <0.00%> (-0.18%) ⬇️
setup.py 0.00% <0.00%> (ø)
sdks/python/apache_beam/portability/python_urns.py 100.00% <0.00%> (ø)
...apache_beam/runners/portability/portable_runner.py 27.37% <0.00%> (ø)
...eam/runners/portability/fn_api_runner/fn_runner.py 24.52% <0.00%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faf76d5...39242ca. Read the comment docs.

@rohdesamuel
Copy link
Contributor Author

R: @pabloem

except grpc.RpcError as e:
# This happens when the Python interpreter shuts down or whn in a
# notebook environment when the kernel is interrupted.
if e.code() == grpc.StatusCode.UNAVAILABLE:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we deal with other statuscodes? Shouldn't we still write the endofstream to the file for other errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I've only seen UNAVAILABLE as a non-error code. But looking at https://developers.google.com/maps-booking/reference/grpc-api/status_codes I think we can also add CANCELLED to not forward the exception.

At L290, we do have a finally clause which will run regardless, so the endofstream will always be written to the channel.

Change-Id: Ic149d64301572201b29813f94bff704e9e7ca778
Copy link
Contributor Author

@rohdesamuel rohdesamuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added CANCELLED to the if statement

except grpc.RpcError as e:
# This happens when the Python interpreter shuts down or whn in a
# notebook environment when the kernel is interrupted.
if e.code() == grpc.StatusCode.UNAVAILABLE:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I've only seen UNAVAILABLE as a non-error code. But looking at https://developers.google.com/maps-booking/reference/grpc-api/status_codes I think we can also add CANCELLED to not forward the exception.

At L290, we do have a finally clause which will run regardless, so the endofstream will always be written to the channel.

@pabloem
Copy link
Member

pabloem commented Sep 1, 2020

Run Portable_Python PreCommit

@pabloem
Copy link
Member

pabloem commented Sep 1, 2020

Run Python2_PVR_Flink PreCommit

@pabloem
Copy link
Member

pabloem commented Sep 1, 2020

LGTM. I'll merge once we get clean runs for tests.

@rohdesamuel
Copy link
Contributor Author

Run Python PreCommit

2 similar comments
@pabloem
Copy link
Member

pabloem commented Sep 1, 2020

Run Python PreCommit

@rohdesamuel
Copy link
Contributor Author

Run Python PreCommit

@pabloem pabloem merged commit 9f4d54a into apache:master Sep 2, 2020
@pabloem
Copy link
Member

pabloem commented Sep 2, 2020

thanks @rohdesamuel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants