Re: An asyncio example

2015-07-05 Thread Adam Bartoš
Terry Reedy wrote: > I suggest you post your minimal example there. User interest in an > issue being fixed and willingness to test patches can help motivate. I've done it. Thank you for help. -- https://mail.python.org/mailman/listinfo/python-list

Re: An asyncio example

2015-07-04 Thread Terry Reedy
On 7/4/2015 3:04 AM, Adam Bartoš wrote: 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'

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 1:07 PM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa >> wrote: >> > >> >>> 1) is there a way to close just one direction of the connection? >> >> >> >> No. SOCK_STREAM sockets are always bidirectional. >> > >> > socket.shutdown(socket.SHUT_WR) does

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa > wrote: > > > >>> 1) is there a way to close just one direction of the connection? > >> > >> No. SOCK_STREAM sockets are always bidirectional. > > > > socket.shutdown(socket.SHUT_WR) does the trick. > > > > I think the asyncio.StreamWriter.write_

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 8:45 AM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >>> Ian Kelly: >>> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop >>> >> is that desired behavior? And why? >>> > >>> > I don't thi

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >> >>> Ian Kelly: >>> >> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>> loop >>> >> >> is that desired behavior? And why? >>> >> > >>> >> > I don't think so. When I tried this locally (using Python 3.4.0, so >>> >

Re: An asyncio example

2015-07-03 Thread Ian Kelly
On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa wrote: > >>> 1) is there a way to close just one direction of the connection? >> >> No. SOCK_STREAM sockets are always bidirectional. > > socket.shutdown(socket.SHUT_WR) does the trick. > > I think the asyncio.StreamWriter.write_eof() is the high-leve

Re: An asyncio example

2015-07-03 Thread Terry Reedy
On 7/3/2015 4:33 PM, Adam Bartoš wrote: On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš mailto:dre...@gmail.com>> wrote: Ian Kelly: >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: > Ian Kelly: > > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the > loop, > >> is that desired behavior? And why? > > > > I don't think so. When I tried this locally (using Python 3.4.0, so > > replacing "async def" with "

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
>> Marko Rauhamaa: >>> socket.shutdown(socket.SHUT_WR) does the trick. >>> >>> I think the asyncio.StreamWriter.write_eof() is the high-level >>> equivalent. >> >> You are right that writer.write_eof() behaves like >> writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) – >> the serve

Re: An asyncio example

2015-07-03 Thread Marko Rauhamaa
Adam Bartoš : > Marko Rauhamaa: >> socket.shutdown(socket.SHUT_WR) does the trick. >> >> I think the asyncio.StreamWriter.write_eof() is the high-level >> equivalent. > > You are right that writer.write_eof() behaves like > writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) – > the

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
Ian Kelly: >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When I tried this locally (using Python 3.4.0, so > replacing "async def" with "def" and "await" with "yield from" and > "loop.create_task" with "as

Re: An asyncio example

2015-07-03 Thread Marko Rauhamaa
>> 1) is there a way to close just one direction of the connection? > > No. SOCK_STREAM sockets are always bidirectional. socket.shutdown(socket.SHUT_WR) does the trick. I think the asyncio.StreamWriter.write_eof() is the high-level equivalent. Marko -- https://mail.python.org/mailman/listinf

Re: An asyncio example

2015-07-03 Thread Ian Kelly
On Fri, Jul 3, 2015 at 8:31 AM, Ian Kelly wrote: > On Fri, Jul 3, 2015 at 4:28 AM, Adam Bartoš wrote: >> Hello, >> >> I'm experimenting with asyncio. I have composed the following code. There is >> a server handler and a client handler. I didn't want to split the code into >> two files so I just

Re: An asyncio example

2015-07-03 Thread Ian Kelly
On Fri, Jul 3, 2015 at 4:28 AM, Adam Bartoš wrote: > Hello, > > I'm experimenting with asyncio. I have composed the following code. There is > a server handler and a client handler. I didn't want to split the code into > two files so I just used a socketpair, inspired by example > https://docs.pyt