comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Call object cleanup method when IDL exits
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Call object cleanup method when IDL exits [message #85620] Thu, 22 August 2013 06:04 Go to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
Dear Folks,

I want to ensure that my object's cleanup method is called when IDL exits.
What's the right way to do this?

The issue is that my object spawns a background process that it subsequently
kills when the object is cleaned up. It appears that IDL does not automatically
call objects' cleanup methods when it shuts down normally.
Consequently, the background process can be left running.

This isn't a problem for well-written programs that explicitly call obj_destroy.
It arises all the time during interactive sessions, however.

Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
other technique to ensure that every object on the heap is cleaned up before
IDL shuts down?

Many thanks,

David
Re: Call object cleanup method when IDL exits [message #85623 is a reply to message #85620] Thu, 22 August 2013 07:31 Go to previous messageGo to next message
Moritz Fischer is currently offline  Moritz Fischer
Messages: 32
Registered: June 2013
Member
Hi David,

sorry, I didn't mean to pm you.
However, I just figured out you can do this:

PRO my_exit
help, LEVEL=-1, OUTPUT=o
funny_array = strsplit( strjoin( o, ' '),' ', /EXTRACT)
foreach var, funny_array do $
tmp = temporary( scope_varfetch(var, LEVEL=-1, /ENTER) )
tmp=42
exit
END

Neverthe less: Let me know if you find something more elegant!

cheers

Am 22.08.2013 15:04, schrieb David Grier:
> Dear Folks,
>
> I want to ensure that my object's cleanup method is called when IDL exits.
> What's the right way to do this?
>
> The issue is that my object spawns a background process that it subsequently
> kills when the object is cleaned up. It appears that IDL does not automatically
> call objects' cleanup methods when it shuts down normally.
> Consequently, the background process can be left running.
>
> This isn't a problem for well-written programs that explicitly call obj_destroy.
> It arises all the time during interactive sessions, however.
>
> Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
> Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
> other technique to ensure that every object on the heap is cleaned up before
> IDL shuts down?
>
> Many thanks,
>
> David
>
Re: Call object cleanup method when IDL exits [message #85628 is a reply to message #85620] Thu, 22 August 2013 10:25 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Thursday, August 22, 2013 9:04:02 AM UTC-4, David Grier wrote:
> Dear Folks,
>
>
>
> I want to ensure that my object's cleanup method is called when IDL exits.
>
> What's the right way to do this?
>
>
>
> The issue is that my object spawns a background process that it subsequently
>
> kills when the object is cleaned up. It appears that IDL does not automatically
>
> call objects' cleanup methods when it shuts down normally.
>
> Consequently, the background process can be left running.
>
>
>
> This isn't a problem for well-written programs that explicitly call obj_destroy.
>
> It arises all the time during interactive sessions, however.
>
>
>
> Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
>
> Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
>
> other technique to ensure that every object on the heap is cleaned up before
>
> IDL shuts down?
>
>
>
> Many thanks,
>
>
>
> David
Re: Call object cleanup method when IDL exits [message #85629 is a reply to message #85623] Thu, 22 August 2013 10:29 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
Hi Moritz,

Thanks for this very helpful response. The only tweak I've added is to test
the strings returned by HELP to make sure that they're valid variable names.
My next step may be to emulate the IDL_STARTUP mechanism by testing
for an IDL_SHUTDOWN environment variable and executing any commands
in the named file before calling exit.

pro my_exit

help, level=-99, output=o
variables = strsplit(strjoin(o,' '),' ',/extract)
foreach var, variables do begin
if idl_validname(var) then begin
tmp = temporary(scope_varfetch(var, level=-1, /enter))
tmp = 42 ; the answer to the question
endif
endforeach
exit

end

All the best,

David


On Thursday, August 22, 2013 10:31:59 AM UTC-4, Moritz Fischer wrote:
> Hi David,
>
>
>
> sorry, I didn't mean to pm you.
>
> However, I just figured out you can do this:
>
>
>
> PRO my_exit
>
> help, LEVEL=-1, OUTPUT=o
>
> funny_array = strsplit( strjoin( o, ' '),' ', /EXTRACT)
>
> foreach var, funny_array do $
>
> tmp = temporary( scope_varfetch(var, LEVEL=-1, /ENTER) )
>
> tmp=42
>
> exit
>
> END
>
>
>
> Neverthe less: Let me know if you find something more elegant!
>
>
>
> cheers
>
>
>
> Am 22.08.2013 15:04, schrieb David Grier:
>
>> Dear Folks,
>
>>
>
>> I want to ensure that my object's cleanup method is called when IDL exits.
>
>> What's the right way to do this?
>
>>
>
>> The issue is that my object spawns a background process that it subsequently
>
>> kills when the object is cleaned up. It appears that IDL does not automatically
>
>> call objects' cleanup methods when it shuts down normally.
>
>> Consequently, the background process can be left running.
>
>>
>
>> This isn't a problem for well-written programs that explicitly call obj_destroy.
>
>> It arises all the time during interactive sessions, however.
>
>>
>
>> Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
>
>> Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
>
>> other technique to ensure that every object on the heap is cleaned up before
>
>> IDL shuts down?
>
>>
>
>> Many thanks,
>
>>
>
>> David
>
>>
Re: Call object cleanup method when IDL exits [message #85630 is a reply to message #85620] Thu, 22 August 2013 10:36 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 8/22/13 7:04 AM, David Grier wrote:
> Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
> Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
> other technique to ensure that every object on the heap is cleaned up before
> IDL shuts down?

The only hook into when IDL exits that I know of is the routine
registered with IDL_ExitRegister in a DLM.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Navigating AVIRIS Images
Next Topic: avoiding "floating illegal operand" errors with /nan keyword in mean

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:39:52 PDT 2025

Total time taken to generate the page: 0.00804 seconds