You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Dyer-Bennet <dd...@dd-b.net> on 2004/11/13 05:36:22 UTC
Flakey behavior
I'm running into flakoid behavior in a script that uses Image::EXIF to
read file information under mod_perl (via Apache::Registry).
Sometimes, without throwing any error or setting the internal error
variable, Image::EXIF reads nothing from the file. I can't correlate
it with anything; a random string of reloads will start producing
different results at a random point.
I've got other scripts running under mod_perl with Apache::Registry;
in fact this started out being an extension to a piece of my photo
gallery, and the other half, that reads IPTC information via
Image::IPTCInfo, works fine.
Any clues? Limitations under mod_perl or Apache::Registry I'm
forgetting? Known problems with Image::EXIF (which I notice is built
over a command-line utility; is the attempt to run the sub-process
where the error is occurring?)? Suggested alternate ways to get EXIF
information from an image file in mod_perl?
Here's the current test script, very much reduced from the application
that initially turned up this behavior:
#! /usr/bin/perl
# Testing Testing Testing
use strict;
use warnings;
use Apache::Util;
use Image::EXIF;
use CGI;
use Data::Dumper;
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX = 5000;
$CGI::DISABLE_UPLOADS = 1;
my $q = new CGI;
my $dir = "/web/dd-b/SnapshotAlbum/data/2004/09180-Birthday";
chdir ($dir) || die "Can't chdir to $dir";
my $fn = $q->param('fn');
die "No such file as $fn" unless -r $fn;
my @res = ();
my $exif = new Image::EXIF ($fn);
push @res, "File: ", $fn;
push @res, "Exif error: $exif->error errstr: ", $exif->errstr;
push @res, "Exif dump: ", Dumper ($exif);
push @res, "Exif data dump: ", Dumper ($exif->get_all_info());
push @res, "Exif error: $exif->error errstr: ", $exif->errstr;
print $q->header,
$q->start_html('test');
print $q->pre(join ("\n", @res));
print $q->end_html;
$exif = undef;
$q = undef;
--
David Dyer-Bennet, <ma...@dd-b.net>, <http://www.dd-b.net/dd-b/>
RKBA: <http://noguns-nomoney.com/> <http://www.dd-b.net/carry/>
Pics: <http://dd-b.lighthunters.net/> <http://www.dd-b.net/dd-b/SnapshotAlbum/>
Dragaera/Steven Brust: <http://dragaera.info/>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Flakey behavior
Posted by David Dyer-Bennet <dd...@dd-b.net>.
Stas Bekman <st...@stason.org> writes:
> David Dyer-Bennet wrote:
>> David Dyer-Bennet <dd...@dd-b.net> writes:
>>
>>>I'm running into flakoid behavior in a script that uses Image::EXIF to
>>>read file information under mod_perl (via Apache::Registry).
>>>Sometimes, without throwing any error or setting the internal error
>>>variable, Image::EXIF reads nothing from the file. I can't correlate
>>>it with anything; a random string of reloads will start producing
>>> different results at a random point.
>> Not solved yet; but setting the same script up as a CGI instead
>> (i.e. copying into /cgi-bin/), it works fine; whatever the problem is
>> it's definitely caused by running under mod_perl. And now that I'm
>> not changing the script so often, I see that it seems
>> to always (nearly always?) run correctly the first time after I change
>> it, and after that it mostly finds null EXIF data. I see a very
>> *very* rare case where it comes up with the right data, so it's not
>> 100.00% failure on reload, but it's close. Still looking for clues!
>
> David, take a look at:
> http://perl.apache.org/docs/1.0/guide/debug.html#Debugging_your_code_in_Single_Server_Mode
> to avoid guessing. If you have a problem in your code, you will see it
> immediately on the second request.
>
> Most likely it's the fault of the module that you are using. Perhaps
> it wasn't written in mind to run under mod_perl. I'd look there
> first. Look for globals first. Then see if there are initialized on
> each request. My guess is that this is your problem. Under mod_cgi you
> can't see that since there is no interpreter persistance. Take some
> time to read:
> http://perl.apache.org/docs/1.0/guide/porting.html#Global_Variables_Persistence
Thanks for the pointers. I've looked at the module code, and the perl
part of it doesn't seem to use global variables or anything nasty.
However, it's just a wrapper around some C code. I'm not sure I want
to start debugging this at that level tonight; I just wanted to drain
the swamp!
I'm now looking at Image::ExifTool, which has a much more recent date
and a higher version number :-); maybe it works!
--
David Dyer-Bennet, <ma...@dd-b.net>, <http://www.dd-b.net/dd-b/>
RKBA: <http://noguns-nomoney.com/> <http://www.dd-b.net/carry/>
Pics: <http://dd-b.lighthunters.net/> <http://www.dd-b.net/dd-b/SnapshotAlbum/>
Dragaera/Steven Brust: <http://dragaera.info/>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Flakey behavior
Posted by Stas Bekman <st...@stason.org>.
David Dyer-Bennet wrote:
> David Dyer-Bennet <dd...@dd-b.net> writes:
>
>
>>I'm running into flakoid behavior in a script that uses Image::EXIF to
>>read file information under mod_perl (via Apache::Registry).
>>Sometimes, without throwing any error or setting the internal error
>>variable, Image::EXIF reads nothing from the file. I can't correlate
>>it with anything; a random string of reloads will start producing
>>different results at a random point.
>
>
> Not solved yet; but setting the same script up as a CGI instead
> (i.e. copying into /cgi-bin/), it works fine; whatever the problem is
> it's definitely caused by running under mod_perl.
>
> And now that I'm not changing the script so often, I see that it seems
> to always (nearly always?) run correctly the first time after I change
> it, and after that it mostly finds null EXIF data. I see a very
> *very* rare case where it comes up with the right data, so it's not
> 100.00% failure on reload, but it's close.
>
> Still looking for clues!
David, take a look at:
http://perl.apache.org/docs/1.0/guide/debug.html#Debugging_your_code_in_Single_Server_Mode
to avoid guessing. If you have a problem in your code, you will see it
immediately on the second request.
Most likely it's the fault of the module that you are using. Perhaps it
wasn't written in mind to run under mod_perl. I'd look there first. Look
for globals first. Then see if there are initialized on each request. My
guess is that this is your problem. Under mod_cgi you can't see that since
there is no interpreter persistance. Take some time to read:
http://perl.apache.org/docs/1.0/guide/porting.html#Global_Variables_Persistence
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Flakey behavior
Posted by David Dyer-Bennet <dd...@dd-b.net>.
David Dyer-Bennet <dd...@dd-b.net> writes:
> I'm running into flakoid behavior in a script that uses Image::EXIF to
> read file information under mod_perl (via Apache::Registry).
> Sometimes, without throwing any error or setting the internal error
> variable, Image::EXIF reads nothing from the file. I can't correlate
> it with anything; a random string of reloads will start producing
> different results at a random point.
Not solved yet; but setting the same script up as a CGI instead
(i.e. copying into /cgi-bin/), it works fine; whatever the problem is
it's definitely caused by running under mod_perl.
And now that I'm not changing the script so often, I see that it seems
to always (nearly always?) run correctly the first time after I change
it, and after that it mostly finds null EXIF data. I see a very
*very* rare case where it comes up with the right data, so it's not
100.00% failure on reload, but it's close.
Still looking for clues!
--
David Dyer-Bennet, <ma...@dd-b.net>, <http://www.dd-b.net/dd-b/>
RKBA: <http://noguns-nomoney.com/> <http://www.dd-b.net/carry/>
Pics: <http://dd-b.lighthunters.net/> <http://www.dd-b.net/dd-b/SnapshotAlbum/>
Dragaera/Steven Brust: <http://dragaera.info/>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html