-
Notifications
You must be signed in to change notification settings - Fork 223
Allowed PythonShell to work with unset std streams #190 #191
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
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 |
|---|---|---|
|
|
@@ -225,6 +225,22 @@ describe('PythonShell', function () { | |
| scriptPath: pythonFolder | ||
| }; | ||
| }) | ||
|
|
||
| it('should run PythonShell normally without access to std streams', function (done) { | ||
| var pyshell = PythonShell.run('exit-code.py', { | ||
| // 3 different ways of assigning values to the std streams in child_process.spawn() | ||
| // * ignore - pipe to /dev/null | ||
| // * inherit - inherit fd from parent process; | ||
| // * process.stderr - pass output directly to that stream. | ||
| stdio: ['ignore', 'inherit', process.stderr], | ||
| args: ["0"] | ||
| }, done); | ||
|
|
||
| should(pyshell.stdin).be.eql(null); | ||
| should(pyshell.stdout).be.eql(null); | ||
| should(pyshell.stderr).be.eql(null); | ||
|
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. Why is stdout and stderr null? Because these both inherit the parent's stdout / stderr shouldn't they have a value? 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. They should be null. The underlying code does a file descriptor dup() so the child process just inherits the file descriptors directly and then all output goes to /dev/tty (for instance, if you are working in a terminal) bypassing any streams in memory in the local process (in the case of using inherit). |
||
| should.throws(() => {pyshell.send("asd")}); | ||
| }); | ||
| }); | ||
|
|
||
| describe('.send(message)', function () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read up on https://nodejs.org/api/child_process.html#child_process_options_stdio, interesting stuff, thanks!