Hello,

I understand the backwards-compatibility concerns. However I have to say
that
the pattern:

    loop.call_soon(loop.stop)
    loop.run_forever()

seems much easier to understand and more logical than:

    loop.stop()
    loop.run_forever()

Show this code to someone who's not familiar with asyncio and ask them what
the result of the second pattern is. I can't imagine anyone getting it
right!

Best regards,

-- 
Aymeric.

2015-11-19 18:30 GMT+01:00 Guido van Rossum <gu...@python.org>:

> OK, I have uploaded a new patch to http://bugs.python.org/issue25593
> that addresses this issue. Please test and let me know!
>
> On Thu, Nov 19, 2015 at 8:44 AM, Guido van Rossum <gu...@python.org>
> wrote:
> > Hm, I wonder if this idiom can actually be saved, as follows:
> >
> > - When a loop is created its _stop flag is False.
> > - Calling stop() sets the _stop flag to True.
> > - Calling run_forever() does *not* reset the _stop flag at the beginning.
> > - However when run_forever() exits it resets the _stop flag to False.
> >
> > Let me work on a new patch for that. (bugs.python.org seems to have
> > some database slowness issues, or maybe it's my hotspot, but I'll get
> > this done ASAP so you can test.)
> >
> > On Thu, Nov 19, 2015 at 7:23 AM, Andrew Svetlov
> > <andrew.svet...@gmail.com> wrote:
> >> Since
> >>     loop.stop()
> >>     loop.run_forever()
> >> is broken in the patch aiohttp test suite as well as almost all my
> >> other libraries and private projects hangs.
> >> Replacing loop.stop() with loop.call_soon(loop.stop) is easy and
> >> obvious fix but the change is required everywhere for all projects.
> >>
> >> Obviously it is backward compatibility break and people will complain
> >> that asyncio starts hanging in new release but worked perfectly before
> >> 3.5.1
> >>
> >> Personally I can live with that if there is no way to keep current
> >> loop.stop() approach.
> >> Maybe we can make `loop.stop()` as shortcut for actual
> >> `loop.call_soon(loop._do_stop())`?
> >
> >
> >
> > --
> > --Guido van Rossum (python.org/~guido)
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
>



-- 
Aymeric.

Reply via email to