I\'d like to know how multiprocessing is done right. Assuming I have a list [1,2,3,4,5]
generated by function f1
which is written to a Queue
Pypeline does this for you. You can even choose between using Processes, Threads or async Tasks. What you want is just e.g. using Processes:
import pypeln as pl
data = some_iterable()
data = pl.process.map(f2, data, workers = 3)
data = list(data)
You can do more complex stuff
import pypeln as pl
data = some_iterable()
data = pl.process.map(f2, data, workers = 3)
data = pl.process.filter(f3, data, workers = 1)
data = pl.process.flat_map(f4, data, workers = 5)
data = list(data)