Sobald ich die Daten in den Arrays habe, verwende ich die Multiprocessing-Funktion pool.starmap, um parallel Metpy-Paketberechnungen auszuführen, die nur auf funktionieren 1D-Arrays. Hier passiert etwas Seltsames. Das Programm scheint nun jahrelang in die äußere Schleife zurückzukehren und beginnt erneut mit der Ausführung von „# begin by processing some files that kommen in yearly format“.
Hier ist mein Code, der ist verallgemeinert, da ich große Probleme hatte, diesen Fehler mit einem viel kleineren Beispiel zu reproduzieren.
Code: Select all
# loop over years
for yr in np.arange(46) + 1979:
# begin by processing some files that come in yearly format
# loop over months
for mo in range(12) + 1:
# open and put data from specific lat/lon points into arrays by variable
# loop over lat/lon locations ("stations")
for station in range(50):
for hr in range(2920):
# fill arrays
# go back to working within outer loop (years) for starting multiprocessing work on filled arrays
with Pool(processes = 16) as pool1:
tw_sfc_pooled = pool1.starmap(mpcalc.wet_bulb_temperature, tw_sfc_argument_list)
bulk_shear_1km_pooled = pool1.starmap(mpcalc.bulk_shear, bulk_shear_1km_argument_list)
many_more_pooled = poo1.starmap(mpcalc.func, many arg lists)
pool1.close() # am I closing this wrong?
pool1.join() # do I need this statement here?
# put pooled lists into final variable arrays for use in work
Ich vermute, dass die Mehrfachverarbeitung in meinem Code entweder nicht richtig gestartet oder gestoppt wird, oder so Es mag es nicht, in einer Schleife zu sein, oder vielleicht entstehen die Probleme durch mehr als 20 pool.starmap-Prozesse. Ich weiß es nicht.
Irgendwelche Gedanken zum Problem?