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

SigInt events get buffered until another key is pressed #165

Closed
thomasballinger opened this issue Sep 25, 2021 · 4 comments
Closed

SigInt events get buffered until another key is pressed #165

thomasballinger opened this issue Sep 25, 2021 · 4 comments

Comments

@thomasballinger
Copy link
Member

thomasballinger commented Sep 25, 2021

import curtsies
import sys
input_generator = curtsies.input.Input(
    keynames="curtsies", sigint_event=True, paste_threshold=None
)

with input_generator as g:
    for x in g:
        print(x)

pressing a, ctrl-c, b, ctrl-c, c, ctrl-d produces

tomb (master) curtsies$ python test.py
a
b
<SigInt Event>
c
<SigInt Event>

so these sigints are waiting for the next key event.

@thomasballinger
Copy link
Member Author

Nevermind, this was just me not understanding how this script worked.

@thomasballinger thomasballinger changed the title SigInt events get buffered until a ctrl-d or return SigInt events get buffered until another key is pressed Sep 25, 2021
@thomasballinger
Copy link
Member Author

Reopened, added Cbreak() and it's still there.

@thomasballinger
Copy link
Member Author

I bet this is it:

Changed in version 3.5: The function is now retried with a recomputed timeout when interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale), instead of raising InterruptedError.
https://docs.python.org/3/library/select.html#select.select

https://www.python.org/dev/peps/pep-0475/ describes the change.

Yep! Fixed by #166

@thomasballinger
Copy link
Member Author

thomasballinger commented Sep 26, 2021

This is a big behavior change (back to how it is documented + used to work)! It seems just better, so I'm ok with possibly breaking consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant