473,399 Members | 2,478 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,399 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 2242
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.