Re: [Interest] how to restart QProcess after it fails?

2019-06-01 Thread Frank Rueter | OHUfx

Thanks Thiago,

that seems to have solved it, i.e. having the slot call a single shot 
timer which triggers the re-run.


Cheers,
frank

On 2/06/19 4:09 AM, Thiago Macieira wrote:

On Saturday, 1 June 2019 00:26:49 PDT Frank Rueter | OHUfx wrote:

I also connect QProcess.stateChanged to another slot which looks like this:

  def __retry_process(self, process_state):

Don't do it from inside that slot. The problem is that the state is still
changing.

Do it at any point after. I recommend using a timer with a non-zero amount of
time, to ensure you're backing off.



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how to restart QProcess after it fails?

2019-06-01 Thread Thiago Macieira
On Saturday, 1 June 2019 00:26:49 PDT Frank Rueter | OHUfx wrote:
> I also connect QProcess.stateChanged to another slot which looks like this:
> 
>  def __retry_process(self, process_state):

Don't do it from inside that slot. The problem is that the state is still 
changing.

Do it at any point after. I recommend using a timer with a non-zero amount of 
time, to ensure you're backing off.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] how to restart QProcess after it fails?

2019-06-01 Thread Frank Rueter | OHUfx

Hi all,

I am using QProcess to launch an external application. The main part 
work without trouble, but I need to check for license errors and if one 
occurred, I need would like to restart the existing process with all 
it's environment settings and signal connections a certain number of times.


I connect QProcess.readyReadStandardError to a slot that toggles an 
attribute called self.in_error to True.

I also connect QProcess.stateChanged to another slot which looks like this:

    def __retry_process(self, process_state):
    max_retries = 5
    if (process_state == QtCore.QProcess.NotRunning) and self.in_error:
            # process has finished in an error state, so try to run it 
again

    self.current_try += 1
    print 'retrying {}/{}'.format(self.current_try, max_retries)
    self.process.start(self.process.program(), 
self.process.arguments())


This prints the line "retrying 1/5" but after that nothing happens. I 
can't see any log output from self.process so if seems to simply not be 
running the second time around.
I thought this would recursively call self.process 5 times after failing 
the first time, since self.process.stateChanged is still connected to 
self__retry_process(), and the current_try attribute is on class level 
where it gets incremented on every unsuccessful try.


I am obviously wrong about that. Could someboy help me out please?

Cheers,
frank
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest