Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-03 Thread Chris Angelico
On Sat, Aug 4, 2018 at 12:03 AM, Oscar Benjamin wrote: > On 2 August 2018 at 20:54, wrote: >> >>> As others have mentioned, separate threads for the individual pipes >>> may help, or if you need to go that far there are specialised >>> libraries, I believe (pexpect is one, but from what I know

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-03 Thread Oscar Benjamin
On 2 August 2018 at 20:54, wrote: > >> As others have mentioned, separate threads for the individual pipes >> may help, or if you need to go that far there are specialised >> libraries, I believe (pexpect is one, but from what I know it's fairly >> Unix-specific, so I'm not very familiar with

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Terry Reedy
On 8/2/2018 3:52 PM, cseber...@gmail.com wrote: subprocess is not meant for interaction through the pipes. That is why, I have been told, IDLE uses a socket for interaction. Multiprocess is apparently better suited for interaction without resorting to a socket. So use normal socket on

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Paul Moore
On Thu, 2 Aug 2018 at 20:58, wrote: > > Sorry, but there's no "simple" answer here for you (although you may > > well be able to get something that works well enough for your specific > > needs - but it's not obvious from your snippet of code what you're > > trying to achieve). > > To send and

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread cseberino
> Another possibility: If the ONLY thing you're doing with stdout/stderr > is passing them through to the screen, simply don't change them. Let > them remain bound to the console. You can have a pipe for stdin > without also having pipes for the others. But that won't work if you > intend to do

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread cseberino
> subprocess is not meant for interaction through the pipes. That is why, > I have been told, IDLE uses a socket for interaction. Multiprocess is > apparently better suited for interaction without resorting to a socket. So use normal socket on localhost for this? Don't you still need

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread cseberino
> As others have mentioned, separate threads for the individual pipes > may help, or if you need to go that far there are specialised > libraries, I believe (pexpect is one, but from what I know it's fairly > Unix-specific, so I'm not very familiar with it). I'm on Linux so pexpect is a

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread cseberino
> -I think the Python interpreter actually sends its output to stderr, so to > capture it you'd probably want it to go to the same place as stdout, so use > stderr = subprocess.STDOUT Yes that captured the error messages! Thanks! > -You're only reading 1 line out output for each thing, so

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Chris Angelico
On Thu, Aug 2, 2018 at 6:46 PM, Paul Moore wrote: > On Wed, 1 Aug 2018 at 21:17, wrote: >> >> I can run python3 interactively in a subprocess w/ Popen but >> if I sent it text, that throws an exception, the process freezes >> instead of just printing the exception like the normal interpreter..

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Paul Moore
On Wed, 1 Aug 2018 at 21:17, wrote: > > I can run python3 interactively in a subprocess w/ Popen but > if I sent it text, that throws an exception, the process freezes > instead of just printing the exception like the normal interpreter.. > why? how fix? Here is my code below. > > (I suspect

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-01 Thread Terry Reedy
On 8/1/2018 4:11 PM, cseber...@gmail.com wrote: I can run python3 interactively in a subprocess w/ Popen but if I sent it text, that throws an exception, the process freezes instead of just printing the exception like the normal interpreter.. why? how fix? Here is my code below. (I suspect

RE: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-01 Thread David Raymond
A couple notes: -I think the Python interpreter actually sends its output to stderr, so to capture it you'd probably want it to go to the same place as stdout, so use stderr = subprocess.STDOUT -You're only reading 1 line out output for each thing, so if 1 command creates multiple lines of

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-01 Thread Chris Angelico
On Thu, Aug 2, 2018 at 6:11 AM, wrote: > I can run python3 interactively in a subprocess w/ Popen but > if I sent it text, that throws an exception, the process freezes > instead of just printing the exception like the normal interpreter.. > why? how fix? Here is my code below. > > (I suspect