On Tue, 10 Nov 2009, Dan Horne wrote:

On Tue, 10 Nov 2009, Dan Horne wrote:

The "die { found => 1 };" instruction sets $@ tp "HASH(0xac2a148) at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/TimeZone/Local/Unix.pm line 115" and hence there is never a $...@->{found}.

What version of DT::TZ? As of 0.92, all uses of $@ should be cleanly local-ized before they are used, so they shouldn't be leaking.

I'm using 1.03. $@ is indeed localised. I don't think anything is leaking. It seems to me that $@ is simply stringyfying the hash, and appending the line number where the error is occurring (i.e. line 115), but I don't know why.

Why it works for some calls and not this particular instance, I'll never know. After bashing my head trying to solve the problem for a couple of days, I have a simple workaround which is undoubtedly more efficient anyway, but which doesn't solve the underlying problem:

our $TZ = DateTime::TimeZone->new( name => 'local' );
sub now {
    my $self = shift;
    return DateTime->now(time_zone => $TZ);
}

This is a really good idea _anyway_. Calculating the local time zone is slow, and it's really unlikely to change over the lifetime of your app. Calculate it once and cache it.


Indeed. The workaround is sufficient for my needs. And if no one cares about why the problem is occurring (why it arises when one module calls DateTime->now but not others), I'm more than happy to let things go!

I'd love to fix it, but I can't without a recipe to reproduce it. I suspect the call to ->now is a red herring. That code path doesn't do anything special with regards to timezones. It probably has something to do with _your_ code that's around the call to ->now and DateTime::TimeZone.


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/

Reply via email to