AttributeError: 'NoneType' object has no attribute 'is_finalizing'

The code seems to be working, but I got error at last.

Exception ignored in: <function Future.del at 0x2b755bdd93a0>
Traceback (most recent call last):
** File “/gpfs/data1/vclgp/xiongl/env/linpy/lib/python3.11/site-packages/distributed/”, line 508, in del**
AttributeError: ‘NoneType’ object has no attribute ‘is_finalizing’

Below is my code:

#!/usr/bin/env python
# coding: utf-8
# library
import glob
import os
from dask.distributed import Client, progress
import dask
import sys
def get_chm(laz_path, norm_out, chm_path):
    norm_laz = norm_out + '/' + os.path.basename(laz_path)
    if os.path.exists(norm_laz): return 0
    os.system(f'wine $LASTOOLS/lasheight.exe -drop_above 150 -drop_below -3  -replace_z -i {laz_path} -odir {norm_out} -olaz ') # -cores 4
    os.system(f'wine $LASTOOLS/blast2dem.exe  -i {norm_laz} -odir {chm_path} -otif ') # -cores 4
    return 1
if __name__ == '__main__':
    file_path = "../data/als_sites_folder.txt"
    my_list = []
    with open(file_path, "r") as file:
        my_list = file.readlines()
    folder_sites = [item.strip() for item in my_list]
    print("Example folder name:", folder_sites[1])
    for folder in folder_sites:
            if folder == '/gpfs/data1/vclgp/data/gedi/imported/usa/plumasnf_20180707/':
                print('## preparing folder')
                region = folder.split('/')[7]
                name = folder.split('/')[8]
                norm_out = '/gpfs/data1/vclgp/xiongl/ProjectIS2CalVal/data/las_norm/' + region + '/' + name
                os.makedirs(norm_out, exist_ok=True)   
                chm_path = '/gpfs/data1/vclgp/xiongl/ProjectIS2CalVal/result_chm/' + region + '/' + name
                os.makedirs(chm_path, exist_ok=True)
                all_laz = glob.glob(folder + '/LAZ_ground/*.laz')
                print('## processing ', name, ', files: ', len(all_laz))
                with Client(n_workers=5, threads_per_worker=1) as client:
                        print(f'## -- dask client opened at: {client.dashboard_link}')
                        cmds = [get_chm(laz_path, norm_out, chm_path) for laz_path in all_laz]  
                        _ = dask.persist(*cmds)
                sys.exit("## -- DONE")

Hi @linxiongumd,

Is this all the error stack trace you’re getting?

What Dask version are you using?

Does it change something if you’re using dask.compute( *cmds) instead of persist, except that you won’t be able to use progress? Does it change something if you remove the sys.exit call?

Hi @guillaumeeb
If I use dask.compute( *cmds), no error is reported.
Maybe it is the command of persist that caused AttribueError?

Well, you never ask for the result of the persisted computation (which I understand you don’t need), so it’s a bit of a weird usage, since you rely on progress to wait for the end of the persist operation. I’m not sure if this is due to persist, progress, or the fact that you never retrieve the result.

Do you really need the progress to be displayed?

basically, I use progress to display the progress bar on the terminal.

Did you try to gather the results after the progress call, this might clean up a bit the workers state.

Today I tried same code, and it didn’t report the attribute error.

That’s good to know, but it might be some race condition and so an intermitent error. Let’s see how it evolve, please post any update on this.