On Tue, Apr 7, 2009 at 1:11 PM, Stevan Little <stevan.lit...@iinteractive.com> wrote: > Matthew, > > You are *not* the first person to do this, which is exactly why we are > telling you that you should not make the assumption of destruction order, we > have been bitten by this as well.
Well, it is worse than that. I don't think the problem is destruction order. I think the problem is related to inheritance, class objects and a bad design decision. You see, what I neglected to show in my examples, because I forgot it was there is this: 1) Inheritance can be divined from the names: LTH LTH::Config LTH::Mqueue LTH::Message LTH::Message::ETN 2) But LTH has a class-level member, called 'config' and it is, um, an LTH::Config. When we create an LTH::Config, we do this: $self->config($self); Now all the LTH objects get the config with no work. But I bet that having a class-static instance of a child class as a member of the parent class is probably NOT a Good Thing at global destruction time; there is probably a bad loop in there. We'll probably rename is Config::LTH so that it does not extend LTH. > Take a look at Devel::GlobalDestruction (which Class::MOP uses, so you > already have it loaded), it will allow you to determine within your DEMOLISH > sub if you are within the scope of Perl's global destruction. Once you know > this, then you can likely just return from your DEMOLISH method since Perl > will automatically clean up all your resources anyway you won't need to care > about ordering. Thanks, I will do that. I do have one DEMOLISH that has to free up potentially open DB handles. If I don't DBI complains. > > - Stevan > > On Apr 7, 2009, at 11:26 AM, Matthew Persico wrote: > >> More experimentation is in order. Even if multiple objects inherit >> from the same parent, you would think that you would get different >> instances and copies of metadata. I cannot be the first person to do >> this with moose. >> >> >> On 4/7/09, Dave Rolsky <auta...@urth.org> wrote: >>> >>> On Mon, 6 Apr 2009, Matthew Persico wrote: >>> >>>> Do I have the diagnosis right? Here are the relevent parts of the >>>> modules. Now, I know that I really don't need these DEMOLISH subs, but >>>> even so, they should work, right? I would think that the destruct >>>> sequence would be >>>> >>>> LTH::Message::ETN >>>> >>>> then, in any order >>>> LTH::Message >>>> LTH::Mqueue >>>> LTH::Config >>>> >>>> and finally >>>> LTH >>>> >>>> Is this a bad assumption? >>> >>> Yes, it is a bad assumption. >>> >>> During global destruction, the order of object destruction is essentially >>> random. >>> >>> One possibility is to try to use an END block to implement some of the >>> destruction behavior, but I don't know where you'd put it, or how it >>> would >>> access the objects you want to access. >>> >>> Another possibility is just to give up and not try to do anything during >>> global destruction. You can use the Devel::GlobalDestruction module to >>> check if you are in global destruction. >>> >>> Note that this has nothing to do with Moose. This is an issue with the >>> Perl interpreter. >>> >>> >>> -dave >>> >>> /*============================================================ >>> http://VegGuide.org http://blog.urth.org >>> Your guide to all that's veg House Absolute(ly Pointless) >>> ============================================================*/ >>> >> >> -- >> Sent from my mobile device >> >> Matthew O. Persico > > -- Matthew O. Persico