471,091 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

How to delete a module file

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


Jul 18 '05 #1
4 2158
On Mon, 28 Feb 2005 16:43:45 +0100, Olivier Ravard
<ol************@novagrid.com> declaimed the following in
comp.lang.python:

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.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #2
Le lundi 28 février 2005 * 17:08 +0000, Dennis Lee Bieber a écrit :
On Mon, 28 Feb 2005 16:43:45 +0100, Olivier Ravard
<ol************@novagrid.com> declaimed the following in
comp.lang.python:

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.


So, what is the solution ?

Jul 18 '05 #3
On Thu, 03 Mar 2005 12:29:58 +0100, Olivier Ravard
<ol************@novagrid.com> declaimed the following in
comp.lang.python:

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}
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #4
Dennis Lee Bieber <wl*****@ix.netcom.com> writes:
On Thu, 03 Mar 2005 12:29:58 +0100, Olivier Ravard
<ol************@novagrid.com> declaimed the following in
comp.lang.python:

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.


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
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by lamar_air | last post: by
14 posts views Thread by ajikoe | last post: by
9 posts views Thread by groleo | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.