Concurrent programming with coroutines in Python

Coroutines is a great paradigm to facilitate concurrent programming. And most of the time, parallel tasks are easily parallelized. The Go is easy to use goroutines to perform parallel tasks. Is there a way to do the same in Python, for example. use coroutines to create processes and synchronize them?

+5
source share
2 answers

Yes, Python supports coroutines in libraries and through generators: for example, in the Greenlet library . In addition, there is a derivative called Stackless Python , which has built-in support for several parallel programming functions, such as microflows and pipes.

Please note that in standard CPython, the Global Interpreter Lock function allows only one thread to start, which can be a problem.

+3
source

If you want to use the standard python interpreter, then this means that the eyepiece library is the way to go.

GIL, . greenlet coroutine . , GIL OS, .

+2

All Articles