[python-win32] Python Error:WindowsError: [Error 32] The process cannot access the file.
manu agarwal
nmanu14387 at gmail.com
Tue Nov 12 13:32:15 CET 2013
Hi ,
I caught the Exception using this code:
try:
print(file)
os.remove(file)
continue
except WindowsError as e:
print e
But i am still not able to delete the files it only caught the exception in
the file and then the script terminates.
Please let me know how can i proceed with the rest of the file to delete.
Thanks
Manu
On Tue, Nov 12, 2013 at 5:47 PM, Tim Golden <mail at timgolden.me.uk> wrote:
> Please reply to the list, not to me personally. I'll answer you there
> when I see it arrive.
>
> Thanks
>
> TJG
>
> On 12/11/2013 12:09, manu agarwal wrote:
> > Hi Tim,
> >
> > Thanks for the Quick Reply.
> >
> > I caught the Exception using this code:
> >
> > try:
> > print(file)
> > os.remove(file)
> > continue
> > except WindowsError as e:
> > print e
> > But i am still not able to delete the files it only caught the exception
> > in the file and then the script terminates.
> >
> > Please let me know how can i proceed with the rest of the file to delete.
> >
> > Thanks
> > Manu Agarwal
> >
> >
> >
> > On Tue, Nov 12, 2013 at 3:42 PM, Tim Golden <mail at timgolden.me.uk
> > <mailto:mail at timgolden.me.uk>> wrote:
> >
> > On 12/11/2013 10:05, manu agarwal wrote:
> > > I am getting the below error while executing the script on one of
> the
> > > application server.
> > >
> > > *WindowsError: [Error 32] The process cannot access the file
> > because it
> > > is being used by another process*
> > > *
> > > *
> > > Script used to delete the files from the server.
> > >
> > > I had used os.remove(file) and tried with os.unlink(file). But it
> is
> > > giving me the same error.
> > >
> > > Is there any way i can skip the files which can not be deleted and
> > > script proceed further to delete other files or it delete the files
> > > forcely without giving this error.
> >
> > Certainly: just catch that particular exception within the loop and
> > continue.
> >
> > (FYI os.remove & os.unlink are the same function under the covers)
> >
> > TJG
> >
> > _______________________________________________
> > python-win32 mailing list
> > python-win32 at python.org <mailto:python-win32 at python.org>
> > https://mail.python.org/mailman/listinfo/python-win32
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20131112/9152b5d7/attachment.html>
More information about the python-win32
mailing list