wxExec Exit problem

Hi,

I have 2 wxPython based applications than for a number of reasons need
to be separate applications but one is normally launched from the other,
(both are either running as python processes or as py2exe builds). Call
them Controller & Listener. Controller launches Listener and needs to
know if it exits so uses wx.Execute Async with a process parameter and
has an OnTerminate handler, it can also send a signal to Listener to
tell it to exit, (e.g. because Controller is about to shut down itself).
(There is other signalling between the two but I don't believe that this
is a part of the problem).

My problem is that if Controller is abnormally terminated, e.g. with a
crash or a debugger stop, Listener will still be running. Shouldn't be a
problem as we can just select the Exit menu item on Listener - this is
where it all goes horribly wrong. Listener starts to shut down and then
hangs. The only way to get rid of the window for it is to use process
explorer and kill it or to shut down & restart the computer.

I have narrowed this down to one of two possibilities:
  1. It is hanging because it is trying to execute the wx.Terminate
callback on the now non-existent launching process, (Controller).
  2. It is hanging because it is trying to print to the pipe created by
wx.Execute which of course also no longer exists.

I have looked at wx.Process.Detach but as the process belongs to the
terminated process, (Controller), calling it within Listener doesn't
seem to do anything.

Any thoughts on what I could try next?

wxPython: 4.0.3 msw
wxWidgets: 3.0.5
Python 3.7.0 & 2.7.13 (32 & 64 bit)
Windows 7 & 10.

···

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.
https://www.avg.com