I've done a lot of web searching, a fair bit of C-source reading, and
quite a lot of miscellaneous head scratching, and I find that I am not
necessarily closer to an ideal solution.
I have a Python/C interface layer that essentially does the following:
Py_XDECREF (some_callback) ;
closeService (some_service);
return;
The problem, of course, is that way back in my Python layer, I have
Objects that are poised to be de-allocated due to the Py_XDECREF call
above; those Objects have __del__ () methods that invoke calls to the
service that is about to be closed in the second line above.
I want to modify the above sequence to manually prompt Python's garbage
collection routine(s) to take over (performance is not an issue here),
similar to the following:
Py_XDECREF (some_callback) ;
PyCollect_Garba ge ();
closeService (some_service);
return;
Is that possible?
I can work around this with additional convoluted tracking of the services
in the C layer, but the problem would disappear entirely if the garbage
collection could be explicitly invoked. I suspect the likely workaround
would involve returning from the above C function, letting Whatever happen
a few times, and only invoking the real closeServce () after I've returned
to the C layer. To wit:
Py_XDECREF (some_callback) ;
markForClosure (some_service);
return;
(( ...time passes in Python-space, and a C function is invoked... ))
if ( servicesNeedClo sing ()) { closeServices (); }
return;
I would prefer, however, an explicit solution, as the above workaround
continues to rely on the assumption that garbage collection occurs
magically at some point when I'm not paying attention.
Solutions I've read about, and/or attempted, and am not wholly interested
in hearing more about:
1. Don't use __del__ methods.
I'm using __del__ methods, which are otherwise doing the right thing
in non-sequence-sensitive situations, so this option is off the table.
2. Don't assume that __del__ methods will be invoked in a timely
fashion.
I'm not making this assumption, but rather, I would like to
*explicitly* assert that garbage collection has occurred.
3. Use the gc module (or PyGC_Collect).
These appear to only address situations with circular references,
which are not my problem-- the Py_XDECREF call makes the right thing
happen, it's just that the garbage collection happens *after* the
service has been properly closed. I've tried inserting calls to
PyGC_Collect (including an invocation of "while (PyGC_Collect() 0)")
with no change in behavior.
Suggestions are welcome.
Cheers,
--Kyle 0 1380 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ganesh |
last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a
process without have access to the process code.
regards
Ganesh
|
by: Rick |
last post by:
Hi,
My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?
Just wondering :)
|
by: Ville Voipio |
last post by:
I would need to make some high-reliability software
running on Linux in an embedded system. Performance
(or lack of it) is not an issue, reliability is.
The piece of software is rather simple, probably a
few hundred lines of code in Python. There is a need
to interact with network using the socket module,
and then probably a need to do something hardware-
related which will get its own driver written in
C.
|
by: Bob lazarchik |
last post by:
Hello:
We are considering developing a time critical system in C#. Our tool used in
Semiconductor production and we need to be able to take meaurements at
precise 10.0 ms intervals( 1000 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no...
|
by: mike2036 |
last post by:
For some reason it appears that garbage collection is releasing an object
that I'm still using. The object is declared in a module and instantiated
within a class that is in turn instantiated by the mainline. The class that
instantiated the object in question is definitely still in existence at the
point garbage collection swoops in and yanks it out from under my processing.
Is there a way to ensure an instantiated object cannot be freed...
| |
by: Johnny E. Jensen |
last post by:
Hellow
I'am not sure what to think about the Garbage Collector.
I have a Class OutlookObject, It have two private variables.
Private Microsoft.Office.Interop.Outlook.Application _Application = null;
Private Microsoft.Office.Interop.Outlook.NameSpace _Namespace = null;
The Constructor:
public OutlookObject()
|
by: rsrinivasan |
last post by:
hi all,
I am using Tomcat4.1. I want to run manually garbage collection. How can i do it?
Thanks,
|
by: Kyle Lanclos |
last post by:
Fredrik Lundh wrote:
The DECREF decrements the reference count, but does not immediately prompt
garbage collection when the reference count drops to zero; that garbage
collection does not appear to occur until I return from the particular C
function I am in the middle of executing.
Ideally, I want to explicitly prompt garbage collection in the middle
of a C function, without first returning to the larger Python interpreter.
|
by: pushpakulkar |
last post by:
Hi all,
Is garbage collection possible in C++. It doesn't come as part of
language support. Is there any specific reason for the same due to the
way the language is designed. Or it is discouraged due to
some specific reason. If someone can give inputs on the same, it will
be of great help.
Regards,
Pushpa
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |