Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
57b64d0d
Commit
57b64d0d
authored
12 years ago
by
Josh Rosen
Browse files
Options
Downloads
Patches
Plain Diff
Fix stdout redirection in PySpark.
parent
7e2e046e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/pyspark/tests.py
+9
-0
9 additions, 0 deletions
python/pyspark/tests.py
python/pyspark/worker.py
+3
-2
3 additions, 2 deletions
python/pyspark/worker.py
with
12 additions
and
2 deletions
python/pyspark/tests.py
+
9
−
0
View file @
57b64d0d
...
...
@@ -108,5 +108,14 @@ class TestAddFile(PySparkTestCase):
self
.
assertEqual
(
"
Hello World!
"
,
UserClass
().
hello
())
class
TestIO
(
PySparkTestCase
):
def
test_stdout_redirection
(
self
):
import
subprocess
def
func
(
x
):
subprocess
.
check_call
(
'
ls
'
,
shell
=
True
)
self
.
sc
.
parallelize
([
1
]).
foreach
(
func
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
python/pyspark/worker.py
+
3
−
2
View file @
57b64d0d
"""
Worker that receives input from Piped RDD.
"""
import
os
import
sys
import
traceback
from
base64
import
standard_b64decode
...
...
@@ -15,8 +16,8 @@ from pyspark.serializers import write_with_length, read_with_length, write_int,
# Redirect stdout to stderr so that users must return values from functions.
old_stdout
=
sys
.
stdout
sys
.
stdout
=
sys
.
stderr
old_stdout
=
os
.
fdopen
(
os
.
dup
(
1
),
'
w
'
)
os
.
dup2
(
2
,
1
)
def
load_obj
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment