New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DESTROY is not called on interpreter exit #5042
Comments
From @autarchHere's an example which might demonstrate why this is important: class C { my $c = C.new; While there are various workarounds, it seems like that all force the _user_ of the class to explicitly account for the need to cleanup threads created by C. It seems like a class should be fully self-contained and capable of cleaning up after itself. |
From @autarchhoelzro++ pointed me to http://irclog.perlgeek.de/perl6/2015-07-22#i_10938226 for some relevant discussion. FWIW, I think the idea of having teardown enabled by default with a switch to disable it from inside code is reasonable(-ish), although there'd have to be a strong culture of "never do this inside a module you want others to use". |
From @lizmat
At exit, all threads are cleaned up automatically anyway, so I don’t really think this is a problem in *this* case. More generally, I think it would be nice if an import would be able to import a LEAVE phaser into the scope: this then would allow code to be executed whenever the importing scope would be left (which an exit would do). $ 6 'LEAVE say "goodbye"; exit’ OTOH, it looks like exit() is not honouring LEAVE phasers either… hmmmm…. Liz |
The RT System itself - Status changed from 'new' to 'open' |
From @autarchOn Tue Jan 12 00:48:59 2016, elizabeth wrote:
Well, it is a problem if your program needs to do something with the thread as part of the cleanup, like set an exit status based on the values that the threads return or something.
An injected LEAVE would be a sort of okay solution, but it really seems like running DESTROY would be the least surprising thing to do. |
From @autarchOn Tue Jan 12 07:11:20 2016, autarch wrote:
I take the first part of this statement back. An injected LEAVE really doesn't work for anything object-related. There's nothing to say that the lexical scope which creates an object is the scope where the object lives: my $o; Injecting a LEAVE there would just make a huge mess. There's really no substitute for DESTROY. |
Migrated from rt.perl.org#127243 (status was 'open')
Searchable as RT127243$
The text was updated successfully, but these errors were encountered: