Running a GUI program haults the calling program (linux)

Kryptxy kryptxy at protonmail.com
Tue Sep 26 04:48:41 EDT 2017


> -------- Original Message --------
> Subject: Re: Running a GUI program haults the calling program (linux)
> Local Time: 26 September 2017 1:26 PM
> UTC Time: 26 September 2017 07:56
> From: __peter__ at web.de
> To: python-list at python.org
>
> Kryptxy via Python-list wrote:
>
>> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>>
>>> -------- Original Message --------
>>> Subject: Re: Running a GUI program haults the calling program (linux)
>>> Local Time: 26 September 2017 12:09 PM
>>> UTC Time: 26 September 2017 06:39
>>> From: cs at cskk.id.au
>>> To: Kryptxy <kryptxy at protonmail.com>
>>> python-list <python-list at python.org>
>>>
>>> On 25Sep2017 20:38, Kryptxy <kryptxy at protonmail.com> wrote:
>>>>I want to run a GUI program (transmission-gtk) from python. This is what
>>>>I do:
>>>>
>>>>import subprocess
>>>>subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE,
>>>>stderr=subprocess.PIPE)
>>>>
>>>>Where `link` is some magnetic link.
>>>>
>>>>This command opens transmission-gtk, but it haults the calling program,
>>>>and keeps the terminal busy till the time GUI is running. As soon as GUI
>>>>is closed, the control goes back to the program.
>>>
>>> I do not believe this is all your code. Please post a _complete_ example.
>>>
>>> Popen dispatches a process. It does not wait for it to terminate. GUI
>>> programs are not special. Therefore, if your calling python program is
>>> blocking, it is blocking somewhere other that this line of code. Please
>>> show us where.
>>>
>>> Consider putting print() calls through your code to locate where your
>>> program stalls.
>>>
>>> Cheers,
>>> Cameron Simpson <cs at cskk.id.au> (formerly cs at zip.com.au)
>>
>> Here -
>>
>> p = subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE,
>> stderr=subprocess.PIPE)
>> output, error = p.communicate()
>
> That"s the problem. communicate() *must* block to collect the program"s
> entire output. You get what you ask for...

Thanks! It worked!


More information about the Python-list mailing list