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

Chris Angelico rosuav at gmail.com
Fri Aug 3 10:06:15 EDT 2018


On Sat, Aug 4, 2018 at 12:03 AM, Oscar Benjamin
<oscar.j.benjamin at gmail.com> wrote:
> On 2 August 2018 at 20:54,  <cseberino at gmail.com> 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 it).
>>
>> I'm on Linux so pexpect is a possibility.
>>
>>> 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 receive text from a subprocess..even when there are exceptions.
>
> You can do this without threads on Linux using select (or similar):
> https://docs.python.org/3.7/library/select.html#select.select
>

Yes, but threads are simpler unless you already know how to use select.

ChrisA



More information about the Python-list mailing list