[Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Terry Reedy

Should the loop.run... methods of asyncio respect KeyboardInterrupt (^C)?

Developer and user convenience and this paragraph in PEP

"However, exceptions deriving only from BaseException are typically not 
caught, and will usually cause the program to terminate with a 
traceback. In some cases they are caught and re-raised. (Examples of 
this category include KeyboardInterrupt and SystemExit ; it is usually 
unwise to treat these the same as most other exceptions.) "


and this examples in the doc (two places)

TCP echo server
# Serve requests until CTRL+c is pressed
print('Serving on {}'.format(server.sockets[0].getsockname()))
try:
loop.run_forever()
except KeyboardInterrupt:
pass

suggest yes.  On the other hand, the section on
"Set signal handlers for SIGINT and SIGTERM"
suggests not, unless an explicit handler is registered and then only on 
Unix.


In any case, Adam Bartos, python-list, "An asyncio example", today asks.
'''
This is a minimal example:

import asyncio

async def wait():
await asyncio.sleep(5)

loop = asyncio.get_event_loop()
loop.run_until_complete(wait())

Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs 
after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?

'''

Using run_forever instead, I found no way to stop other than killing the 
process (Idle or Command Prompt).


--
Terry Jan Reedy

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Guido van Rossum
I think this may be more of a Windows issue than an asyncio issue. I agree
that ideally ^C should take effect immediately (as it does on UNIX).

On Sat, Jul 4, 2015 at 9:54 AM, Terry Reedy  wrote:

> Should the loop.run... methods of asyncio respect KeyboardInterrupt (^C)?
>
> Developer and user convenience and this paragraph in PEP
>
> "However, exceptions deriving only from BaseException are typically not
> caught, and will usually cause the program to terminate with a traceback.
> In some cases they are caught and re-raised. (Examples of this category
> include KeyboardInterrupt and SystemExit ; it is usually unwise to treat
> these the same as most other exceptions.) "
>
> and this examples in the doc (two places)
>
> TCP echo server
> # Serve requests until CTRL+c is pressed
> print('Serving on {}'.format(server.sockets[0].getsockname()))
> try:
> loop.run_forever()
> except KeyboardInterrupt:
> pass
>
> suggest yes.  On the other hand, the section on
> "Set signal handlers for SIGINT and SIGTERM"
> suggests not, unless an explicit handler is registered and then only on
> Unix.
>
> In any case, Adam Bartos, python-list, "An asyncio example", today asks.
> '''
> This is a minimal example:
>
> import asyncio
>
> async def wait():
> await asyncio.sleep(5)
>
> loop = asyncio.get_event_loop()
> loop.run_until_complete(wait())
>
> Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs
> after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?
> '''
>
> Using run_forever instead, I found no way to stop other than killing the
> process (Idle or Command Prompt).
>
> --
> Terry Jan Reedy
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread R. David Murray
Once long ago in Internet time (issue 581232) time.sleep on windows was
not interruptible and this was fixed.  Is it possible the work on EINTR
has broken that fix?

(I don't currently have 3.5 installed on windows to test that theory...)

On Sat, 04 Jul 2015 17:46:34 +0200, Guido van Rossum  wrote:
> I think this may be more of a Windows issue than an asyncio issue. I agree
> that ideally ^C should take effect immediately (as it does on UNIX).
> 
> On Sat, Jul 4, 2015 at 9:54 AM, Terry Reedy  wrote:
> 
> > Should the loop.run... methods of asyncio respect KeyboardInterrupt (^C)?
> >
> > Developer and user convenience and this paragraph in PEP
> >
> > "However, exceptions deriving only from BaseException are typically not
> > caught, and will usually cause the program to terminate with a traceback.
> > In some cases they are caught and re-raised. (Examples of this category
> > include KeyboardInterrupt and SystemExit ; it is usually unwise to treat
> > these the same as most other exceptions.) "
> >
> > and this examples in the doc (two places)
> >
> > TCP echo server
> > # Serve requests until CTRL+c is pressed
> > print('Serving on {}'.format(server.sockets[0].getsockname()))
> > try:
> > loop.run_forever()
> > except KeyboardInterrupt:
> > pass
> >
> > suggest yes.  On the other hand, the section on
> > "Set signal handlers for SIGINT and SIGTERM"
> > suggests not, unless an explicit handler is registered and then only on
> > Unix.
> >
> > In any case, Adam Bartos, python-list, "An asyncio example", today asks.
> > '''
> > This is a minimal example:
> >
> > import asyncio
> >
> > async def wait():
> > await asyncio.sleep(5)
> >
> > loop = asyncio.get_event_loop()
> > loop.run_until_complete(wait())
> >
> > Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs
> > after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?
> > '''
> >
> > Using run_forever instead, I found no way to stop other than killing the
> > process (Idle or Command Prompt).
> >
> > --
> > Terry Jan Reedy
> >
> > ___
> > Python-Dev mailing list
> > Python-Dev@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > https://mail.python.org/mailman/options/python-dev/guido%40python.org
> >
> 
> 
> 
> -- 
> --Guido van Rossum (python.org/~guido)
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> https://mail.python.org/mailman/options/python-dev/rdmurray%40bitdance.com
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Guido van Rossum
It's possible, but AFAIK asyncio.sleep() has nothing in common with
time.sleep() -- it's implemented as a timeout on select() or on the IOCP
loop. (I also have no access to Windows ATM.)

On Sat, Jul 4, 2015 at 7:49 PM, R. David Murray 
wrote:

> Once long ago in Internet time (issue 581232) time.sleep on windows was
> not interruptible and this was fixed.  Is it possible the work on EINTR
> has broken that fix?
>
> (I don't currently have 3.5 installed on windows to test that theory...)
>
> On Sat, 04 Jul 2015 17:46:34 +0200, Guido van Rossum 
> wrote:
> > I think this may be more of a Windows issue than an asyncio issue. I
> agree
> > that ideally ^C should take effect immediately (as it does on UNIX).
> >
> > On Sat, Jul 4, 2015 at 9:54 AM, Terry Reedy  wrote:
> >
> > > Should the loop.run... methods of asyncio respect KeyboardInterrupt
> (^C)?
> > >
> > > Developer and user convenience and this paragraph in PEP
> > >
> > > "However, exceptions deriving only from BaseException are typically not
> > > caught, and will usually cause the program to terminate with a
> traceback.
> > > In some cases they are caught and re-raised. (Examples of this category
> > > include KeyboardInterrupt and SystemExit ; it is usually unwise to
> treat
> > > these the same as most other exceptions.) "
> > >
> > > and this examples in the doc (two places)
> > >
> > > TCP echo server
> > > # Serve requests until CTRL+c is pressed
> > > print('Serving on {}'.format(server.sockets[0].getsockname()))
> > > try:
> > > loop.run_forever()
> > > except KeyboardInterrupt:
> > > pass
> > >
> > > suggest yes.  On the other hand, the section on
> > > "Set signal handlers for SIGINT and SIGTERM"
> > > suggests not, unless an explicit handler is registered and then only on
> > > Unix.
> > >
> > > In any case, Adam Bartos, python-list, "An asyncio example", today
> asks.
> > > '''
> > > This is a minimal example:
> > >
> > > import asyncio
> > >
> > > async def wait():
> > > await asyncio.sleep(5)
> > >
> > > loop = asyncio.get_event_loop()
> > > loop.run_until_complete(wait())
> > >
> > > Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs
> > > after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?
> > > '''
> > >
> > > Using run_forever instead, I found no way to stop other than killing
> the
> > > process (Idle or Command Prompt).
> > >
> > > --
> > > Terry Jan Reedy
> > >
> > > ___
> > > Python-Dev mailing list
> > > Python-Dev@python.org
> > > https://mail.python.org/mailman/listinfo/python-dev
> > > Unsubscribe:
> > > https://mail.python.org/mailman/options/python-dev/guido%40python.org
> > >
> >
> >
> >
> > --
> > --Guido van Rossum (python.org/~guido)
> > ___
> > Python-Dev mailing list
> > Python-Dev@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/rdmurray%40bitdance.com
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Andrew Svetlov
I believe it's a bug #23057 http://bugs.python.org/issue23057

On Sat, Jul 4, 2015 at 10:58 PM, Guido van Rossum  wrote:
> It's possible, but AFAIK asyncio.sleep() has nothing in common with
> time.sleep() -- it's implemented as a timeout on select() or on the IOCP
> loop. (I also have no access to Windows ATM.)
>
> On Sat, Jul 4, 2015 at 7:49 PM, R. David Murray 
> wrote:
>>
>> Once long ago in Internet time (issue 581232) time.sleep on windows was
>> not interruptible and this was fixed.  Is it possible the work on EINTR
>> has broken that fix?
>>
>> (I don't currently have 3.5 installed on windows to test that theory...)
>>
>> On Sat, 04 Jul 2015 17:46:34 +0200, Guido van Rossum 
>> wrote:
>> > I think this may be more of a Windows issue than an asyncio issue. I
>> > agree
>> > that ideally ^C should take effect immediately (as it does on UNIX).
>> >
>> > On Sat, Jul 4, 2015 at 9:54 AM, Terry Reedy  wrote:
>> >
>> > > Should the loop.run... methods of asyncio respect KeyboardInterrupt
>> > > (^C)?
>> > >
>> > > Developer and user convenience and this paragraph in PEP
>> > >
>> > > "However, exceptions deriving only from BaseException are typically
>> > > not
>> > > caught, and will usually cause the program to terminate with a
>> > > traceback.
>> > > In some cases they are caught and re-raised. (Examples of this
>> > > category
>> > > include KeyboardInterrupt and SystemExit ; it is usually unwise to
>> > > treat
>> > > these the same as most other exceptions.) "
>> > >
>> > > and this examples in the doc (two places)
>> > >
>> > > TCP echo server
>> > > # Serve requests until CTRL+c is pressed
>> > > print('Serving on {}'.format(server.sockets[0].getsockname()))
>> > > try:
>> > > loop.run_forever()
>> > > except KeyboardInterrupt:
>> > > pass
>> > >
>> > > suggest yes.  On the other hand, the section on
>> > > "Set signal handlers for SIGINT and SIGTERM"
>> > > suggests not, unless an explicit handler is registered and then only
>> > > on
>> > > Unix.
>> > >
>> > > In any case, Adam Bartos, python-list, "An asyncio example", today
>> > > asks.
>> > > '''
>> > > This is a minimal example:
>> > >
>> > > import asyncio
>> > >
>> > > async def wait():
>> > > await asyncio.sleep(5)
>> > >
>> > > loop = asyncio.get_event_loop()
>> > > loop.run_until_complete(wait())
>> > >
>> > > Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs
>> > > after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?
>> > > '''
>> > >
>> > > Using run_forever instead, I found no way to stop other than killing
>> > > the
>> > > process (Idle or Command Prompt).
>> > >
>> > > --
>> > > Terry Jan Reedy
>> > >
>> > > ___
>> > > Python-Dev mailing list
>> > > Python-Dev@python.org
>> > > https://mail.python.org/mailman/listinfo/python-dev
>> > > Unsubscribe:
>> > > https://mail.python.org/mailman/options/python-dev/guido%40python.org
>> > >
>> >
>> >
>> >
>> > --
>> > --Guido van Rossum (python.org/~guido)
>> > ___
>> > Python-Dev mailing list
>> > Python-Dev@python.org
>> > https://mail.python.org/mailman/listinfo/python-dev
>> > Unsubscribe:
>> > https://mail.python.org/mailman/options/python-dev/rdmurray%40bitdance.com
>> ___
>> Python-Dev mailing list
>> Python-Dev@python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe:
>> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com
>



-- 
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Terry Reedy

On 7/4/2015 4:06 PM, Andrew Svetlov wrote:

I believe it's a bug #23057 http://bugs.python.org/issue23057

On Sat, Jul 4, 2015 at 10:58 PM, Guido van Rossum  wrote:

It's possible, but AFAIK asyncio.sleep() has nothing in common with
time.sleep() -- it's implemented as a timeout on select() or on the IOCP
loop. (I also have no access to Windows ATM.)


Thanks all.  I replied back to OP on python-list.

--
Terry Jan Reedy

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should asyncio ignore KeyboardInterrupt?

2015-07-04 Thread Victor Stinner
Signal handling is not implemented in asyncio on Windows. I have  working
patch for that somewhere, it's not merged yet.

UDP and SSL are also missing on Windows. Good news: SSL support comes with
Python 3.5!

Victor
Le 4 juil. 2015 09:55, "Terry Reedy"  a écrit :

> Should the loop.run... methods of asyncio respect KeyboardInterrupt (^C)?
>
> Developer and user convenience and this paragraph in PEP
>
> "However, exceptions deriving only from BaseException are typically not
> caught, and will usually cause the program to terminate with a traceback.
> In some cases they are caught and re-raised. (Examples of this category
> include KeyboardInterrupt and SystemExit ; it is usually unwise to treat
> these the same as most other exceptions.) "
>
> and this examples in the doc (two places)
>
> TCP echo server
> # Serve requests until CTRL+c is pressed
> print('Serving on {}'.format(server.sockets[0].getsockname()))
> try:
> loop.run_forever()
> except KeyboardInterrupt:
> pass
>
> suggest yes.  On the other hand, the section on
> "Set signal handlers for SIGINT and SIGTERM"
> suggests not, unless an explicit handler is registered and then only on
> Unix.
>
> In any case, Adam Bartos, python-list, "An asyncio example", today asks.
> '''
> This is a minimal example:
>
> import asyncio
>
> async def wait():
> await asyncio.sleep(5)
>
> loop = asyncio.get_event_loop()
> loop.run_until_complete(wait())
>
> Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs
> after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?
> '''
>
> Using run_forever instead, I found no way to stop other than killing the
> process (Idle or Command Prompt).
>
> --
> Terry Jan Reedy
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com