in reply to Object Destructors and Signals
I'm having trouble getting the desctructor to work properly. Sometimes the database handle gets destroyed before my object's destructor is called and I get a cascade of errors.
Your object is a global variable or it is referenced by one. It is surviving past the end of all lexical scopes, forcing Perl to guess how to destroying what's left in memory. During global destruction, Objects can be destroyed in any order.
The direct solution would be to not use a global variable, or clean up the global yourself sooner. END{} could also help.
That said, the real reason you are having a problem is because your design fails hard. It needs to do something reliably under exceptional circumstances. Adjust your design so it fails safe, and you won't need to do anything during destruction. Perhaps transactions could be of use.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Object Destructors and Signals (optimization)
by tye (Sage) on Nov 05, 2010 at 04:41 UTC | |
by ikegami (Patriarch) on Nov 05, 2010 at 16:22 UTC |