-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-29582][PYSPARK] Support TaskContext.get() in a barrier task from Python side
#26239
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
Changes from all commits
c8fe7cc
e3e5872
a55fb6b
dc89212
04a2b0e
384e1d2
74e3515
7d0f0d2
a3d14c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -503,6 +503,9 @@ def main(infile, outfile): | |
| if isBarrier: | ||
| taskContext = BarrierTaskContext._getOrCreate() | ||
| BarrierTaskContext._initialize(boundPort, secret) | ||
| # Set the task context instance here, so we can get it by TaskContext.get for | ||
| # both TaskContext and BarrierTaskContext | ||
| TaskContext._setTaskContext(taskContext) | ||
| else: | ||
| taskContext = TaskContext._getOrCreate() | ||
| # read inputs for TaskContext info | ||
|
|
@@ -596,6 +599,11 @@ def process(): | |
| profiler.profile(process) | ||
| else: | ||
| process() | ||
|
|
||
| # Reset task context to None. This is a guard code to avoid residual context when worker | ||
| # reuse. | ||
| TaskContext._setTaskContext(None) | ||
| BarrierTaskContext._setTaskContext(None) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, what happens if it fails with exceptions in the middle of execution in this worker?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it really needed? We always set the global TaskContext and never reset it previouslly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If exceptions occured, the worker will be closed with
Previously: This code is just a guard program, it shouldn't increase extra overhead or behavior change.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I guess that's only when the worker is reused. Can you clarify it with comments here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for reviewing. updated. |
||
| except Exception: | ||
| try: | ||
| exc_info = traceback.format_exc() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.