473,245 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 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 2235
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: lamar_air | last post by:
I have a python script and i want to delete a file on my computer c:\....\...\.. .txt what's the script to do this? I know how to write to files but i also need to know how to delete a file.
0
by: | last post by:
Hi! I need to fresh a zip-archive using zipfile. However, it seems it is no function to fresh the archive. When I use the append-mode of ZipFile, the written file is merely appended to the...
14
by: ajikoe | last post by:
Hello, If I use os.remove(fileName), does it always assure that the code will move to the next code only if the fileName is deleted completely? Pujo
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
3
by: richardkreidl | last post by:
I have the following module that I delete old files based on how old they are: Sub Main() Dim First_Date As String = Date.Today.AddDays(-7) Dim Archive_Files() As String =...
9
by: groleo | last post by:
Hi list. Simple question: is it possible to override the global new/delete operators, without using malloc/free? I mean something in the ideea of the code below, which doesnt work cause of...
2
by: jasone | last post by:
Hi, A section of my database allows users to delete items from a table, there is only one collumn in the table, this contains module information(parts of a manufacturing line) due to the lines...
2
by: Viewer T. | last post by:
I am trying to write a script that deletes certain files based on certain criteria. What I am trying to do is to automate the process of deleting certain malware files that disguise themselves...
2
by: gbin,Zhou | last post by:
Hi,all. I see from "http://docs.python.org/tut/node11.html" that "Name spaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.