How to delete a module file

O

Olivier Ravard

Hi everybody,

My application enables the developpment of new C++
modules that are dynamically loaded in this
application.

My problem is that (under Windows) I can't delete a
module that have been already imported. I must
exiting the application (which is not a good idea for
a developpment environnment).
i.e. I can't delete "module.pyd" if I made "import
module" in the python interpreter.

Is there some technics to "unload" modules under python ? or is there a
technic to force removing a file even it is used by another
application ?

Remark : This problem does not exist under Linux.

Thanks for your answers and ideas.

Olivier
 
D

Dennis Lee Bieber

Remark : This problem does not exist under Linux.
I think Linux just masks the situation. Windows won't let you
delete the file because the OS still has it open (linked) to the process
that did the import.

Linux deletes the directory entry, so other programs can't find
the file -- but the OS still has an unseen link to the actual file; the
actual file doesn't go away until the total link count falls to 0.

--
 
O

Olivier Ravard

Le lundi 28 février 2005 à 17:08 +0000, Dennis Lee Bieber a écrit :
I think Linux just masks the situation. Windows won't let you
delete the file because the OS still has it open (linked) to the process
that did the import.

Linux deletes the directory entry, so other programs can't find
the file -- but the OS still has an unseen link to the actual file; the
actual file doesn't go away until the total link count falls to 0.

So, what is the solution ?
 
D

Dennis Lee Bieber

So, what is the solution ?
As the old joke concludes... "... stop doing that".

I don't think Windows has any means to delete a file that it
considers open. You might be able to /rename/ it to something else
(since the OS knows where the "open" file is, it doesn't care about the
name anymore), but the delete still has to be done after all users of
the file have closed it.

Linux sort of does the same thing, but it "renames" to "no
directory entry", /and/ automatically deletes when the file is
subsequently closed. {again, this is my understanding -- I'm not an
expert at file systems}


--
 
T

Thomas Heller

Dennis Lee Bieber said:
As the old joke concludes... "... stop doing that".

I don't think Windows has any means to delete a file that it
considers open. You might be able to /rename/ it to something else
(since the OS knows where the "open" file is, it doesn't care about the
name anymore), but the delete still has to be done after all users of
the file have closed it.

Even if you are able to remove/rename the file, it won't help you
anyway, because there's no way to reload an extension module in a sane
way. AFAIK.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,222
Messages
2,571,137
Members
47,754
Latest member
Armand37T7

Latest Threads

Top