Is there any map-like method which doesn't load all sub-processes in memory at once, instead, if total CPU threads is four, it firstly load four process and execute it, if one of four finishes, it will load another one and replace this.
The pool.map in standard library just loads all of jobs at once, and execute them in random order. If there was a large amount of jobs to execute, the memory will overflow.
I have read the official documentation of Python3 , I don't find any related material yet.
The feature I required is too detailed, I don't think there is any third-part library which implement this feature on purpose.
What I expected:
There is four core computer.
y = XXX.map(f,range(1,100))
if 1~4 doesn't finish, there is no f(5) in system memory. When one of these four tasks finishes, for example f(2), it will load f(5) at the position of f(2).
Let's talk about the feature of function 'f'. f is a heavy memory consuming function, its instance have to take up about huge amount of memory.