Thanks for the prompt response.
Resetting self.in_error won't have any effect at this stage, it's just an attribute I made up.

I just tried creating a new process, passing the environment and signal connections on from the original process, and that works, e.g.:

                exe = self.process.program()
                args = self.process.arguments()
                env = self.process.environment()

                self.process = QtCore.QProcess(self)
                self.process.setEnvironment(env)
self.process.readyReadStandardError.connect(self.__react_to_error)
self.process.readyReadStandardOutput.connect(self.__print_nuke_output)
self.process.stateChanged.connect(self.__retry_process)

                self.process.start(exe, nuke_args)

But I feel I shouldn't have to do this, right?

Maybe I need to reset something on the original process QProcess instance before it is willing to run again?

This is with PySide2 and QT 5.11.1 btw, using PyQt is not an option for me.

Cheers,
frank

On 1/06/19 8:06 PM, Zhao Lee wrote:
1.
You should reset self.in_error=False in __retry_process to get __retry_process called again , as a good practice , I would get ride of self.in_error
and use
if (process_state == QtCore.QProcess.NotRunning) and self.current_try < 5
instead .
2.
If the above solution didn't work, maybe there is a bug with PySide, please give a try with PyQt5.




:


At 2019-06-01 15:26:49, "Frank Rueter | OHUfx" <fr...@ohufx.com> wrote:
>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
>_______________________________________________
>PySide mailing list
>PySide@qt-project.org
>https://lists.qt-project.org/listinfo/pyside



_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside

Reply via email to