"Marko Rauhamaa"  wrote in message news:8737sumpjl....@elektro.pacujo.net...

"Frank Millman" <fr...@chagford.com>:

> Using asyncio, there are times when I want to execute a coroutine which
> is time-consuming. I do not need the result immediately, and I do not
> want to block the current task, so I want to run it in the background.

You can't run code "in the background" using asyncio. Coroutines perform
cooperative multitasking in a single thread on a single CPU.

Parallel processing requires the use of threads or, often preferably,
processes.

To put it in another way, never run time-consuming code in asyncio.


No arguments there.

I started with a task that ran quickly, but as I added stuff it started to slow down.

The execution of the task involves calling some existing functions, which are themselves coroutines. As you have noted elsewhere, once you turn one function into a coroutine, all calls higher up the chain have to be coroutines as well.

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.

Hope this makes sense.

Frank


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to