knossos-project / knossos_utils

Python library for interacting with KNOSSOS data sets and annotation files
GNU General Public License v2.0
9 stars 9 forks source link

knossosdataset seg.zip file locking broken #21

Open jmrk84 opened 5 years ago

jmrk84 commented 5 years ago

Under some circumstances, this lock mechanism (which looks very fishy upon superficial inspection, a semaphore is certainly something different) appears to fail, leading to ugly race conditions during knossos dataset writing (line 1928):


                  while True:
                    try:
                        os.makedirs(folder_path+"block")    # Semaphore --------
                        break
                    except:
                        if time.time() - \
                                os.stat(folder_path+"block").st_mtime > 5:
                            os.rmdir(folder_path+"block")
                            os.makedirs(folder_path+"block")
                            break
                        time.sleep(1)`