Running a GUI program haults the calling program (linux)

Kryptxy kryptxy at protonmail.com
Tue Sep 26 03:20:34 EDT 2017


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 6:20 AM
> UTC Time: 26 September 2017 00:50
> From: rosuav at gmail.com
> To: python-list <python-list at python.org>
>
> On Tue, Sep 26, 2017 at 10:38 AM, Kryptxy via Python-list
> <python-list at python.org> 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.
>>
>> Is there any way that the GUI program is opened, and immediately the control returns to calling program, instead of keeping the terminal busy?
>>
>> (I know transmission-remote can be used for adding torrents. Looking for a way around for transmission-gtk specifically).
>
> I"m not sure why you can"t signal it, but I"ll take that parenthesized
> comment as an indication that you know about (a) the
> transmission-remote command, and/or (b) the fact that transmission-gtk
> can be remote-controlled fairly effectively. (For instance, I have a
> script that puts Transmission into turtle mode, then does something,
> and then takes Transmission out of turtle mode. It"s two lines of
> shell script to do it.)

Yes I know about transmission-remote. I am trying to figure out a way for running transmission-gtk without causing program to hault.

> So, you want to "fire-and-forget" a GUI program. Or more generally,
> _any_ program. My suspicion here is that, since Popen shouldn"t be
> blocking, that you"re filling up one of your pipes. Can you try
> removing the stdout and stderr parameters, and see what that does? You
> should be able to fire off a subprocess and then carry on with the
> program. It might make a lot of noise, if transmission produces a ton
> of output; but if that happens, try std{out,err}=subprocess.DEVNULL
> instead of PIPE - unless you"re specifically trying to read the
> output?

Tried std{out,err}=subprocess.DEVNULL - Did not work. The program still haults.

Also, worth noting that the program haults when transmission-gtk is opened for the first time.
Suppose if the GUI windows is already open, and then subprocess.Popen() is run,
the torrent is added successfully, and control goes back to calling program. (That is the program does not hault).


More information about the Python-list mailing list