Search code examples
pythonmultiprocessinggdal

Execute Python pool.map or pool.apply_async methods in reversed order


I have a script that is iterating through ~40 years of data.

I'm iterating through a list of input monthly files in order, and then assigning those input files to an output function.

Is it possible to reverse my multiprocessing mapped threads to run this data from newest to oldest?

if not exists(outfname):
     pool.apply_async(perc_normal, args = [allfiles[i], normfname, maskfname, outfname, fill, 0, indir])

I'm familiar with the reversed() function in a list, but not sure how to apply it as I'm assigning pool maps here.


Solution

  • instead of using

    for i in range(len(allfiles)):
    

    use

    for i in range(len(allfiles),-1,-1):
    

    to reverse the order of iteration.