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

switch results to different pipe #116

Merged
merged 21 commits into from
May 3, 2020
Merged

switch results to different pipe #116

merged 21 commits into from
May 3, 2020

Conversation

Almenon
Copy link
Owner

@Almenon Almenon commented Apr 24, 2020

It simplifies the code if results come in on a different pipe and also that way prints don't interfere with the results.

To fix Almenon/AREPL-vscode#327

@Almenon
Copy link
Owner Author

Almenon commented Apr 24, 2020

I tried adding another pipe but all I/O stopped working... great :(

First I tried [process.stdin, process.stdout, process.stderr, 'pipe']
Then I tried ['pipe', 'pipe', 'pipe', 'pipe'] - no dice either

Maybe I should just try getting custom pipes working with stdout/stdin first and then expand.

@Almenon
Copy link
Owner Author

Almenon commented Apr 26, 2020

@Almenon Almenon force-pushed the switch_to_diff_fd branch from 6a144e5 to cf38d95 Compare April 26, 2020 03:47
@Almenon
Copy link
Owner Author

Almenon commented May 3, 2020

dump got a error because the result_stream object is None ~ possibly because result_stream is only initialized if arepl_python_evaluator is executed directly. I tried moving the opening of the stream to the print_output function using with open(3,'w') as f but unlike regular files once you close the stream you can't open it again. Then I tested opening it without closing but same problem - I'm guessing when the function exits the object is garbage collected and close is called.

I need to somehow have the stream be a global object shared with dump.

@Almenon
Copy link
Owner Author

Almenon commented May 3, 2020

Note that when I run the test I got:

C:\dev\AREPL-backend>npm test

> arepl-backend@1.3.7 test C:\dev\AREPL-backend
> mocha -r ts-node/register --ui tdd *.test.ts --exit



  python_evaluator Tests
Starting Python...
    1) "before all" hook


  0 passing (229ms)
  1 failing

  1) python_evaluator Tests
       "before all" hook:
     Uncaught TypeError: self.stderrParser is not a function
      at C:\dev\AREPL-backend\node_modules\python-shell\index.ts:395:68
      at Array.forEach (<anonymous>)
      at PythonShell.receiveInternal (node_modules\python-shell\index.ts:393:15)
      at PythonShell.receiveStderr (node_modules\python-shell\index.ts:374:21)
      at Socket.<anonymous> (node_modules\python-shell\index.ts:153:22)
      at addChunk (_stream_readable.js:288:12)
      at readableAddChunk (_stream_readable.js:269:11)
      at Socket.Readable.push (_stream_readable.js:224:10)
      at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

Python-shell fails because this.stderr is true so it listens to data event of stderr and calls receiveStderr which calls recieveInternal which calls stderrParser but stderrParser is null due to binary mode. I'll have to either fix it or adapt my code.

@Almenon
Copy link
Owner Author

Almenon commented May 3, 2020

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 2
- Added 2
           

Complexity increasing per file
==============================
- python/arepl_python_evaluator.py  2
- python/arepl_result_stream.py  1
         

See the complete overview on Codacy

@Almenon Almenon changed the title WIP switch results to different pipe switch results to different pipe May 3, 2020
@Almenon
Copy link
Owner Author

Almenon commented May 3, 2020

Other changes this PR introduces:

@Almenon Almenon merged commit ec781b4 into master May 3, 2020
@Almenon Almenon deleted the switch_to_diff_fd branch May 3, 2020 16:55
@Almenon
Copy link
Owner Author

Almenon commented May 3, 2020

🎉 This PR is included in version 1.3.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Stops working with end parameter from print method
1 participant