operating system - Python: Can't save file/Windows Error 32 -


i have written function called when program done job.

def alldone(self, event):     dlg = wx.messagebox("all done!", "ask alfred", wx.ok | wx.icon_information)     os.unlink(self.fpath)     os.rename(self.temp, self.fpath)     self.pathbox.clear() 

however, not working expected. supposed delete original file, rename temp file original files path.

instead, executing unlink, deleting file @ self.fpath.

the exact error is:

file "g:/asknorbert/finder.py", line 151, in alldone os.rename(self.temp, self.fpath) windowserror: [error 32] process cannot access file because being used process 

make sure have called flush() , close() on temporary file before attempting rename it, ensure not locking it.

it worth calling time.sleep(0.2), give os time finish doing, after close , before rename.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -