This is my error:
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
I call the function below from a worker thread, when its done its long running process. It stops the thread and then gives it 10 secs before showing a dialog box and renaming the file. "Unlocker" shows that the file is only open in Python.exe.
def allDone(self, event):
myClass.worker.stop()
for i in range(0,10):
time.sleep(1)
print(i)
dlg = wx.MessageBox("All done!", "Ask Alfred", wx.OK | wx.ICON_INFORMATION)
os.rename(self.tempf, self.tempf+"123.xls")
self.Destroy()
The file gets opened in the code via xlrd methods below in the worker thread:
rbook=xlrd.open_workbook(self.file)
sheet = rbook.sheet_by_index(0)
wbook = copy(rbook)