Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading warning message of _expect_expr() at KeyboardInterrupt #6661

Closed
simon-king-jena opened this issue Jul 31, 2009 · 7 comments
Closed

Comments

@simon-king-jena
Copy link
Member

When there is a KeyboardInterrupt while _expect_expr talks with some interface, there is always the warning message

Control-C pressed.  Interrupting R. Please wait a few seconds...

before the KeyboardInterrupt is re-raised -- regardless whether the interface is R or anything else!

The patch that I am about to post would instead print

"Control-C pressed.  Interrupting %s. Please wait a few seconds..."%self

where self is the interface.

Component: interfaces

Keywords: KeyboardInterrupt

Author: Simon King

Reviewer: Minh Van Nguyen

Merged: Sage 4.1.1.rc1

Issue created by migration from https://trac.sagemath.org/ticket/6661

@simon-king-jena
Copy link
Member Author

Fixing a misleading warning message in _expect_expr, with doc test included

@simon-king-jena

This comment has been minimized.

@simon-king-jena
Copy link
Member Author

Author: Simon King

@simon-king-jena
Copy link
Member Author

comment:2

Attachment: trac_6661_expect_expr.patch.gz

Meanwhile there also is a doc test (thank you for pointing me to the "alarm" function, William!), so, I think the patch is ready for review!

Now, we have a better warning message:

sage: print sage0.eval("alarm(1); singular._expect_expr('1')")
Control-C pressed.  Interrupting Singular. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/king/.sage/temp/gauss/29173/_home_king__sage_init_sage_0.py in <module>()

/home/king/SAGE/sage-4.1/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    838                 else:
    839                     break
--> 840             raise KeyboardInterrupt, msg
    841
    842     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds
sage: print sage0.eval("alarm(1); gap._expect_expr('1')")
Control-C pressed.  Interrupting Gap. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/king/.sage/temp/gauss/29173/_home_king__sage_init_sage_0.py in <module>()

/home/king/SAGE/sage-4.1/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    838                 else:
    839                     break
--> 840             raise KeyboardInterrupt, msg
    841
    842     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds

Note that it correctly says "Interrupting Singular" or "Interrupting Gap".

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Aug 3, 2009

comment:3

Before patch:

----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: print sage0.eval("alarm(1); singular._expect_expr('1')")
Control-C pressed.  Interrupting R. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/23333/_home_mvngu__sage_init_sage_0.py in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    830                 else:
    831                     break
--> 832             raise KeyboardInterrupt, msg
    833 
    834     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds
sage: print sage0.eval("alarm(1); gap._expect_expr('1')")
Control-C pressed.  Interrupting R. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/23333/_home_mvngu__sage_init_sage_0.py in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    830                 else:
    831                     break
--> 832             raise KeyboardInterrupt, msg
    833 
    834     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds

The error message should say that it's interrupting Singular or GAP, not R. Now after the patch:

----------------------------------------------------------------------
| Sage Version 4.1.1.rc0, Release Date: 2009-07-29                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
sage: print sage0.eval("alarm(1); singular._expect_expr('1')")
Control-C pressed.  Interrupting Singular. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/23479/_home_mvngu__sage_init_sage_0.py in <module>()

/scratch/mvngu/release/sage-4.1.1.rc0/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    838                 else:
    839                     break
--> 840             raise KeyboardInterrupt, msg
    841 
    842     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds
sage: print sage0.eval("alarm(1); gap._expect_expr('1')")
Control-C pressed.  Interrupting Gap. Please wait a few seconds...
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/23479/_home_mvngu__sage_init_sage_0.py in <module>()

/scratch/mvngu/release/sage-4.1.1.rc0/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
    838                 else:
    839                     break
--> 840             raise KeyboardInterrupt, msg
    841 
    842     def _sendstr(self, str):

KeyboardInterrupt: computation timed out because alarm was set for 1 seconds

The error message now correctly says that it's interrupting Singular or GAP. So positive review.

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Aug 3, 2009

Merged: Sage 4.1.1.rc1

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Aug 3, 2009

Reviewer: Minh Van Nguyen

@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Aug 3, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants