Ticket #9361: 9361_maxima_timeout.patch

File 9361_maxima_timeout.patch, 1.5 KB (added by jdemeyer, 9 years ago)
  • sage/interfaces/maxima.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1326467013 -3600
    # Node ID 26c8a4da1672929f993e3483ecd72e2e23f38be9
    # Parent  d8b48887d936c944a048b318c2c90156c539ea28
    In the maxima interface, send at most one interrupt.
    
    diff --git a/sage/interfaces/maxima.py b/sage/interfaces/maxima.py
    a b  
    834834        cmd = '''0;sconcat("%s",(%s+1));\n'''%(marker,r)
    835835        self._sendstr(cmd)
    836836        try:
    837             self._expect_expr(timeout=0.5)
    838             if not s in self._before():
    839                 self._expect_expr(s,timeout=0.5)
     837            try:
    840838                self._expect_expr(timeout=0.5)
    841         except pexpect.TIMEOUT, msg:
    842             self._interrupt()
     839                if not s in self._before():
     840                    self._expect_expr(s,timeout=0.5)
     841                    self._expect_expr(timeout=0.5)
     842            except pexpect.TIMEOUT:
     843                # Don't call self._interrupt() here, as that might send multiple
     844                # interrupts.  On OS X 10.4, maxima takes a long time to
     845                # process one interrupt (7.5 seconds on an idle system, but up
     846                # to a minute on a loaded system) and gets confused by multiple
     847                # interrupts.  Instead, send just one interrupt and wait.
     848                # See Trac #9361.
     849                self._sendstr(chr(3))
     850                self._expect_expr(timeout=120)
    843851        except pexpect.EOF:
    844852            self._crash_msg()
    845853            self.quit()