Re: Recipe request: asyncio "spin off coroutine"

2016-12-15 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87mvfxirba@elektro.pacujo.net... It ain't over till the fat lady sings. Things can accumulate, hang and/or fail in surprising ways. At the very least you should maintain statistics that reveal the number of pending closing tasks for troubleshooting wh

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
"Frank Millman" : > "Marko Rauhamaa" wrote in message news:87vaulitxe@elektro.pacujo.net... >> >> "Frank Millman" : >> >> > I changed 'await self.close()', to > >> 'asyncio.ensure_future(self.close())'. >> > >> > Problem solved. >> >> A nice insight. >> >> However, shouldn't somebody somewher

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87vaulitxe@elektro.pacujo.net... "Frank Millman" : > I changed 'await self.close()', to > 'asyncio.ensure_future(self.close())'. > > Problem solved. A nice insight. However, shouldn't somebody somewhere in your code be keeping track of the returne

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
"Frank Millman" : > I changed 'await self.close()', to 'asyncio.ensure_future(self.close())'. > > Problem solved. A nice insight. However, shouldn't somebody somewhere in your code be keeping track of the returned task? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmoFyJqYw4G_kNo5Sn=ULyjgm=kexqrqvwubr87evbz...@mail.gmail.com... When you work with threads, it's pretty straight-forward to spin off another thread: you start it. Your current thread continues, and the other one runs in parallel. What's the most str

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 7:53 AM, Ian Kelly wrote: > On Wed, Dec 14, 2016 at 12:53 PM, Chris Angelico wrote: >> On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >>> Chris Angelico : >>> asyncio.spin_off(parallel()) # ??? [...] What code should go on the "???" li

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Ian Kelly
On Wed, Dec 14, 2016 at 12:53 PM, Chris Angelico wrote: > On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> asyncio.spin_off(parallel()) # ??? >>> >>> [...] >>> >>> What code should go on the "???" line to accomplish this? >> >> asyncio.ensure_future(parallel()

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 7:25 AM, Marko Rauhamaa wrote: > What version of Python are you running? > >Changed in version 3.5.1: The function accepts any awaitable object. > 3.7 :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> asyncio.spin_off(parallel()) # ??? >>> >>> [...] >>> >>> What code should go on the "???" line to accomplish this? >> >> asyncio.ensure_future(parallel()) > > Hmm. I tried that but it didn't w

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> asyncio.spin_off(parallel()) # ??? >> >> [...] >> >> What code should go on the "???" line to accomplish this? > > asyncio.ensure_future(parallel()) Hmm. I tried that but it didn't work in the full program (it hung

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
Chris Angelico : > asyncio.spin_off(parallel()) # ??? > > [...] > > What code should go on the "???" line to accomplish this? asyncio.ensure_future(parallel()) Marko -- https://mail.python.org/mailman/listinfo/python-list

Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
When you work with threads, it's pretty straight-forward to spin off another thread: you start it. Your current thread continues, and the other one runs in parallel. What's the most straight-forward way to do this in asyncio? I know this has been asked before, but threads keep devolving, and I can