wxPython and grace_np

Hi,
there is some kind of conflict when trying to use grace_np (python wrapper for xmgrace) together with wxPython.

This is what I get:

Exception exceptions.AttributeError: "GraceProcess instance has no attribute 'pipe'" in <bound method GraceProcess.__del__ of <grace_np.GraceProcess instance at 0x415bd4ac>> ignored
Traceback (most recent call last):
   File "/usr/lib/python2.3/site-packages/grace_np.py", line 142, in __init__
     signal.signal(signal.SIGCHLD, signal.SIG_IGN)
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

Any ideas?
Christian

Christian Kristukat wrote:

Hi,
there is some kind of conflict when trying to use grace_np (python wrapper for xmgrace) together with wxPython.

Which version of wxPython? What platform? Where can we find out more about grace_np? How are you combining the two?

This is what I get:

Exception exceptions.AttributeError: "GraceProcess instance has no attribute 'pipe'" in <bound method GraceProcess.__del__ of <grace_np.GraceProcess instance at 0x415bd4ac>> ignored
Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/grace_np.py", line 142, in __init__
    signal.signal(signal.SIGCHLD, signal.SIG_IGN)
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

wxPython will do this when the App object is created:

  signal.signal(signal.SIGINT, signal.SIG_DFL)

but I don't know how that can cause problems with signal.SIGCHLD??

···

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

Robin Dunn wrote:

Christian Kristukat wrote:

Hi,
there is some kind of conflict when trying to use grace_np (python wrapper for xmgrace) together with wxPython.

Which version of wxPython? What platform? Where can we find out more

wxPython 2.4.1.2 for python 2.3 on SuSE linux 9.0

about grace_np? How are you combining the two?

You can find a copy of grace_np.py on http://www.idyll.org/~n8gray/code/ (look for gracePlot.py). It basically starts xmgrace in a pipe and passes commands to it.

I quote the interesting parts - the error is reported at the signal call:

-----------------------------snip
# Python, by default, ignores SIGPIPE signals anyway
#signal.signal(signal.SIGPIPE, signal.SIG_IGN)

# Don't exit when our child "grace" exits (which it could if
# the user clicks on `exit'):
signal.signal(signal.SIGCHLD, signal.SIG_IGN)

# Make the pipe that will be used for communication:
(fd_r, fd_w) = os.pipe()
cmd = cmd + ('-dpipe', `fd_r`)

# Fork the subprocess that will start grace:
self.pid = os.fork()

# If we are the child, replace ourselves with grace
if self.pid == 0:
     try:
         # This whole thing is within a try block to make sure
         # the child can't escape.
         for i in range(OPEN_MAX):
             # close everything except stdin, stdout, stderr
             # and the read part of the pipe
             if i not in (fd_r,0,1,2):
                 try:
                     os.close(i)
                 except OSError:
                     pass
         try:
             os.execvp('xmgrace', cmd)
         except:
             # we have to be careful in the child process. We
             # don't want to throw an exception because that would
             # allow two threads to continue running.
             sys.stderr.write('GraceProcess: Could not start xmgrace\n')
             os._exit(1) # exit this forked process but not the parent
     except:
         sys.stderr.write('Unexpected exception in child!\n')
         os._exit(2) # exit child but not parent

# We are the parent -> keep only the writeable side of the pipe
os.close(fd_r)
---------------------------snap

I already found at that when commenting out the signal call it works anyway but I'm not sure about the consequences.

Christian