How handle a linux/unix signal when wxPython is used ?

Hello,

i try to use

signal.signal(signal.SIGUSR1, self.signal_handler)

and

def signal_handler(self, signum, frame):
    print "Signal handler called with signal %d" % (signum)

in my wxApp

class AppPyLisiere(wxApp):
    """ Main application object."""
    def OnInit(self):

or in my main frame

class FrameMain(wxFrame):
    """ Main frame."""
    def __init__(self, *args, **kwds):

but it's always the same, i launch the application, i send a SIGUSR1
signal with "kill -10 PID" and nothing append, the print is done only when
i close the application.

You can try to open a wxMessageBox, it will open only when you close the
application.

In an application without GUI, it works fine but not when i use wxPython,
is there a special way to handle the signal ?

Thank you :slight_smile:

···

--

Freedom - Share - Respect

rangzen wrote:
[...]

but it's always the same, i launch the application, i send a SIGUSR1
signal with "kill -10 PID" and nothing append, the print is done only when
i close the application.

You can try to open a wxMessageBox, it will open only when you close the
application.

In an application without GUI, it works fine but not when i use wxPython,
is there a special way to handle the signal ?

I've investigated this before and never found a solution, nor even an idea of what the cause might be. The signal handlers just are not called until after MainLoop returns. If anybody wants to look into this I'll gladly apply a patch that fixes it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

rangzen wrote:

but it's always the same, i launch the application, i send a SIGUSR1
signal with "kill -10 PID" and nothing append, the print is done only when
i close the application.

In an application without GUI, it works fine but not when i use wxPython,
is there a special way to handle the signal ?

I've investigated this before and never found a solution, nor even an idea of what the cause might be. The signal handlers just are not called until after MainLoop returns. If anybody wants to look into this I'll gladly apply a patch that fixes it.

could you setup and use all the signal handling code in another thread? then you'd need to use wxCallAfter() or the like to notify your app.

It may be worth a try.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Robin Dunn wrote:

rangzen wrote:

but it's always the same, i launch the application, i send a SIGUSR1
signal with "kill -10 PID" and nothing append, the print is done only when
i close the application.

In an application without GUI, it works fine but not when i use wxPython,
is there a special way to handle the signal ?

I've investigated this before and never found a solution, nor even an idea of what the cause might be. The signal handlers just are not called until after MainLoop returns. If anybody wants to look into this I'll gladly apply a patch that fixes it.

could you setup and use all the signal handling code in another thread? then you'd need to use wxCallAfter() or the like to notify your app.

No, Python only delivers signals to the main thread.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!