[issue28212] Closing server in asyncio is not efficient

2017-12-21 Thread Andrew Svetlov
Andrew Svetlov added the comment: Superseded by https://bugs.python.org/issue32391 -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Add StreamWriter.wait_closed() ___ Python tracker

[issue28212] Closing server in asyncio is not efficient

2016-10-27 Thread Andrew Svetlov
Andrew Svetlov added the comment: >From my perspective the problem is: many asyncio calls schedules a delayed >activity internally. E.g. `task.cancel()` doesn't cancels immediately but requires at least one extra loop iteration. The same is true for `transport.close()` -- it doesn't close

[issue28212] Closing server in asyncio is not efficient

2016-10-26 Thread Константин Волков
Константин Волков added the comment: Seems that my example wasn`t good. Real reason in it was that closing server is not closing already established connections, and seems that it is not expected to do. Andrew, can you provide your example? I catched some problems but now I think it was

[issue28212] Closing server in asyncio is not efficient

2016-10-21 Thread Yury Selivanov
Yury Selivanov added the comment: > Seems that its not so hard - in loop.remove_reader add If you have a patch in mind, please create a PR on github.com/python/asyncio -- ___ Python tracker

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Константин Волков
Константин Волков added the comment: Seems that its not so hard - in loop.remove_reader add self._ready.append(reader) after reader.cancel() May be its needed to check that its not already there, but I cant imagine how it can be. 2016-09-20 23:16 GMT+03:00 Andrew Svetlov

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Andrew Svetlov
Andrew Svetlov added the comment: It's a known annoying issue. Honestly I don't know how to fix it properly. `transport.close()` is affected also because `protocol.connection_lost()` is called on next loop iteration only. Adding a small `asyncio.sleep()` between finishing all worn and loop

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Константин Волков
Константин Волков added the comment: Attached file with test example. There in "ping" task "except" and "finally" sections never called as expected (but code inside "try" will work). Server is closed while client connection is active, and it just removes reading task from loop. You can still

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Константин Волков
Константин Волков added the comment: Yes? may be a in a hour, 2016-09-20 18:12 GMT+03:00 Guido van Rossum : > > Guido van Rossum added the comment: > > Can you please supply a complete example? > > --Guido (mobile) > > -- > >

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Guido van Rossum
Guido van Rossum added the comment: Can you please supply a complete example? --Guido (mobile) -- ___ Python tracker ___

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Константин Волков
Константин Волков added the comment: Thats not a thing I talking about. But thanks for "wait_closed", I will be use it in future ) Im talking about reading tasks.When reader removed from selector, there is reading task for it. Loop do "cancel" for it, but it not really cancelling task. Its only

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread R. David Murray
R. David Murray added the comment: You have to call wait_closed to complete the shutdown. This should probably be mentioned directly in the socket server docs (at least in the examples) (assuming I'm not wrong...but I'm pretty sure I'm right) rather than by implicit reference to Server via

[issue28212] Closing server in asyncio is not efficient

2016-09-20 Thread Константин Волков
New submission from Константин Волков: When you close asyncio socket server it closes all connection sockets, remove its readers and do "cancel" for readers. Problem is that, that after this reader tasks are leaved alone in "cancelling" state. They wouldn`t be really cancelled, because they