Github messages for voidlinux
 help / color / mirror / Atom feed
* [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken
@ 2022-02-19 23:44 tornaria
  2022-02-21 12:10 ` tornaria
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tornaria @ 2022-02-19 23:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2866 bytes --]

New issue by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712

Description:
Correct behaviour (using python):
```
$ python
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cypari2.pari_instance import Pari
>>> a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)
>>> a.factor() # takes ~ 1/2 hour
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cypari2/gen.pyx", line 4361, in cypari2.gen.Gen.factor
KeyboardInterrupt
>>> 
```
After running `a.factor()` I hit control-C (the statement takes ~ half hour to finish). Since this is running extension code (pari C library) python is not catching signals; that's why cypari uses cysignals which is supposed to catch the signal and raise the `KeyboardInterrupt`.

But when running the same code using ipython nothing happens:
```
$ ipython
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from cypari2.pari_instance import Pari

In [2]: a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)

In [3]: a.factor() # takes 1/2 hour
^C^C^C^C^C
```

This bug affects our sagemath which is using our system packages for ipython, cypari2, cysignals, etc. When using the vendored version of these packages in sagemath, this works ok:
```
$ ./sage -ipython
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from cypari2.pari_instance import Pari

In [2]: a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)

In [3]: a.factor()
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-3-af0555404bb2> in <module>
----> 1 a.factor()

cypari2/gen.pyx in cypari2.gen.Gen.factor()

KeyboardInterrupt: 

In [4]: 
```
It's possible that there's something about our packages that is breaking signal handling.

For the record, the package versions are:
 - ipython: 7.31.0 in void, 7.29.0 in sagemath
 - cypari2: 2.1.2 in void, 2.1.2 in sagemath
 - cysignals: 1.11.2 in void, 1.10.3 in sagemath

Downgrading system ipython to 7.29.0 (which I happen to have in my cache) doesn't fix the issue. I will try to build cysignals-1.10.3 as a void package (since 1.11.2 is the first version to be shipped in void) and see if that changes anything.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Control-C on ipython (on extension code using cysignals) is broken
  2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
@ 2022-02-21 12:10 ` tornaria
  2022-02-21 12:20 ` tornaria
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2022-02-21 12:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712#issuecomment-1046810660

Comment:
The issue is fixed by downgrading `python3-prompt_toolkit` to `3.0.24_1`, with every other package as currently in the repos (including the recent update to ipython 8.0.1).

The issue is present with prompt_toolkit 3.0.26_1 so it seems to be a regression between 3.0.24 and 3.0.26 (I don't have 3.0.25 in my cache).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Control-C on ipython (on extension code using cysignals) is broken
  2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
  2022-02-21 12:10 ` tornaria
@ 2022-02-21 12:20 ` tornaria
  2022-02-21 12:26 ` tornaria
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2022-02-21 12:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712#issuecomment-1046819645

Comment:
There's a strong smell in the [changelog](https://raw.githubusercontent.com/prompt-toolkit/python-prompt-toolkit/master/CHANGELOG) for 3.0.25 and 3.0.26:
```
3.0.26: 2022-01-27
------------------

Fixes:
- Fixes issue introduced in 3.0.25: Don't handle SIGINT on Windows.


3.0.25: 2022-01-27
------------------

Fixes:
- Use `DummyOutput` when `sys.stdout` is `None` and `DummyInput` when
  `sys.stdin` is `None`. This fixes an issue when the code runs on windows,
  using pythonw.exe and still tries to interact with the terminal.
- Correctly reset `Application._is_running` flag in case of exceptions in some
  situations.
- Handle SIGINT (when sent from another process) and allow binding it to a key
  binding. For prompt sessions, the behavior is now identical to pressing
  control-c.
- Increase the event loop `slow_duration_callback` by default to 0.5. This
  prevents printing warnings if rendering takes too long on slow systems.
```

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Control-C on ipython (on extension code using cysignals) is broken
  2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
  2022-02-21 12:10 ` tornaria
  2022-02-21 12:20 ` tornaria
@ 2022-02-21 12:26 ` tornaria
  2022-02-21 13:34 ` tornaria
  2022-02-28  2:25 ` [ISSUE] [CLOSED] " ahesford
  4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2022-02-21 12:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1159 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712#issuecomment-1046819645

Comment:
There's a strong smell in the [changelog](https://raw.githubusercontent.com/prompt-toolkit/python-prompt-toolkit/master/CHANGELOG) for 3.0.25 and 3.0.26:
```
3.0.26: 2022-01-27
------------------

Fixes:
- Fixes issue introduced in 3.0.25: Don't handle SIGINT on Windows.


3.0.25: 2022-01-27
------------------

Fixes:
- Use `DummyOutput` when `sys.stdout` is `None` and `DummyInput` when
  `sys.stdin` is `None`. This fixes an issue when the code runs on windows,
  using pythonw.exe and still tries to interact with the terminal.
- Correctly reset `Application._is_running` flag in case of exceptions in some
  situations.
- Handle SIGINT (when sent from another process) and allow binding it to a key
  binding. For prompt sessions, the behavior is now identical to pressing
  control-c.
- Increase the event loop `slow_duration_callback` by default to 0.5. This
  prevents printing warnings if rendering takes too long on slow systems.
```

Edit: built 3.0.25 which is already broken.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Control-C on ipython (on extension code using cysignals) is broken
  2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
                   ` (2 preceding siblings ...)
  2022-02-21 12:26 ` tornaria
@ 2022-02-21 13:34 ` tornaria
  2022-02-28  2:25 ` [ISSUE] [CLOSED] " ahesford
  4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2022-02-21 13:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712#issuecomment-1046887486

Comment:
Reported upstream: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ISSUE] [CLOSED] Bug: Control-C on ipython (on extension code using cysignals) is broken
  2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
                   ` (3 preceding siblings ...)
  2022-02-21 13:34 ` tornaria
@ 2022-02-28  2:25 ` ahesford
  4 siblings, 0 replies; 6+ messages in thread
From: ahesford @ 2022-02-28  2:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2869 bytes --]

Closed issue by tornaria on void-packages repository

https://github.com/void-linux/void-packages/issues/35712

Description:
Correct behaviour (using python):
```
$ python
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cypari2.pari_instance import Pari
>>> a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)
>>> a.factor() # takes ~ 1/2 hour
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cypari2/gen.pyx", line 4361, in cypari2.gen.Gen.factor
KeyboardInterrupt
>>> 
```
After running `a.factor()` I hit control-C (the statement takes ~ half hour to finish). Since this is running extension code (pari C library) python is not catching signals; that's why cypari uses cysignals which is supposed to catch the signal and raise the `KeyboardInterrupt`.

But when running the same code using ipython nothing happens:
```
$ ipython
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from cypari2.pari_instance import Pari

In [2]: a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)

In [3]: a.factor() # takes 1/2 hour
^C^C^C^C^C
```

This bug affects our sagemath which is using our system packages for ipython, cypari2, cysignals, etc. When using the vendored version of these packages in sagemath, this works ok:
```
$ ./sage -ipython
Python 3.10.2 (main, Jan 15 2022, 03:11:32) [GCC 10.2.1 20201203]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from cypari2.pari_instance import Pari

In [2]: a = Pari()(54853908712446157179434453567343931596301333824416758692208077566613224454501131209)

In [3]: a.factor()
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-3-af0555404bb2> in <module>
----> 1 a.factor()

cypari2/gen.pyx in cypari2.gen.Gen.factor()

KeyboardInterrupt: 

In [4]: 
```
It's possible that there's something about our packages that is breaking signal handling.

For the record, the package versions are:
 - ipython: 7.31.0 in void, 7.29.0 in sagemath
 - cypari2: 2.1.2 in void, 2.1.2 in sagemath
 - cysignals: 1.11.2 in void, 1.10.3 in sagemath

Downgrading system ipython to 7.29.0 (which I happen to have in my cache) doesn't fix the issue. I will try to build cysignals-1.10.3 as a void package (since 1.11.2 is the first version to be shipped in void) and see if that changes anything.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-28  2:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-19 23:44 [ISSUE] Bug: Control-C on ipython (on extension code using cysignals) is broken tornaria
2022-02-21 12:10 ` tornaria
2022-02-21 12:20 ` tornaria
2022-02-21 12:26 ` tornaria
2022-02-21 13:34 ` tornaria
2022-02-28  2:25 ` [ISSUE] [CLOSED] " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).