Hello Dynamo Friends
When reading CSV-files i ran into the problem of getting the Windows Error:
The process cannot access the file because another process has locked a portion of the file
This was because opening and closing the CSV was sensitive to error, this was improved by using the “With” method. But for about 2-5% of runs the problem remains.
So let´s solve that problem by looping the reading process until it works, there are just some things i don´t know how to handle.
First draft:
timeout = time.time() + 120 #seconds
bool = True
while bool == True:
time.sleep(0.5) # sleep for 500 milliseconds
if time.time() > timeout:
syncresult="timeout"
break
with io.open(SlogFilePath,"r", encoding = "utf-16(LE)") as File:
FILE = File.read().splitlines()
if READING_DID_WORK:
bool = False
else:
bool = True
OUT = FILE
-
How can i check if READING_DID_WORK? Just checking if FILE = List, or is there a better way. FILE could also be an empty list, so that case has to be covered.
-
Is there a way to induce that failing access problem? Because i have to test my code somehow!
Happy about any advice
kind regards!