On Tue, Oct 17, 2017 at 9:44 PM, Brendan Barnwell <brenb...@brenbarn.net> wrote:
> On 2017-10-17 07:26, Serhiy Storchaka wrote: > >> 17.10.17 17:06, Nick Coghlan пише: >> >>> >Keep in mind we're not talking about a regular loop you can break out of >>> >with Ctrl-C here - we're talking about a tight loop inside the >>> >interpreter internals that leads to having to kill the whole host >>> >process just to get out of it. >>> >> And this is the root of the issue. Just let more tight loops be >> interruptible with Ctrl-C, and this will fix the more general issue. >> > > I was just thinking the same thing. I think in general it's > always bad for code to be uninterruptible with Ctrl-C. Indeed I agree about this. > If these infinite iterators were fixed so they could be interrupted, this > containment problem would be much less painful. > > I'm unable to reproduce the "uninterruptible with Ctrl-C" problem with infinite iterators. At least itertools doesn't seem to have it: >>> import itertools >>> for i in itertools.count(): ... pass ... ^CTraceback (most recent call last): File "<stdin>", line 1, in <module> KeyboardInterrupt >>> for i in itertools.repeat(1): ... pass ... ^CTraceback (most recent call last): File "<stdin>", line 1, in <module> KeyboardInterrupt >>> for i in itertools.cycle((1,)): ... pass ... ^CTraceback (most recent call last): File "<stdin>", line 1, in <module> KeyboardInterrupt >>> Same thing on both Windows and Linux, Python 3.6. ––Koos -- + Koos Zevenhoven + http://twitter.com/k7hoven +
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/