asyncio - run coroutine in the background

Frank Millman frank at chagford.com
Mon Feb 15 03:17:28 EST 2016


"Paul Rubin"  wrote in message 
news:87h9ha8lt0.fsf at jester.gateway.pace.com...
>
> "Frank Millman" <frank at chagford.com> writes:
> > The benefit of my class is that it enables me to take the coroutine
> > and run it in another thread, without having to re-engineer the whole
> > thing.
>
> Threads in Python don't get you parallelism either, of course.
>

Agreed. My class does not alter the total time taken, but it does free up 
the original task to carry on with other work.

run_in_executor() uses threads by default, but it does allow you to specify 
processes as an alternative.

> I haven't used async/await yet and it's looking painful.  I've been
> wanting to read this:
>
>  http://www.snarky.ca/how-the-heck-does-async-await-work-in-python-3-5
>
> but I start to think it isn't all that great an approach to concurrency.
>

Thanks for that link. I had a quick scan, and it looks interesting, but some 
of it a bit above my head. I have bookmarked it, as I think that as my 
understanding increases, I will gain more from it on each re-read.

Frank





More information about the Python-list mailing list