Subject: | Is HTTP::Cache::Transparent thread safe? |
This program always fails if I include HTTP::Cache::Transparent, however
if you comment out the call to HTTP::Cache::Transparent::init, it fails
with:
HTML::Form::parse: No $base_uri provided at
/usr/local/share/perl/5.14.2/WWW/Mec
hanize.pm line 2664.
#!/usr/bin/perl -w
use Parallel::Simple qw(prun);
use HTTP::Cache::Transparent;
use WWW::Mechanize::Cached::GZip;
HTTP::Cache::Transparent::init( {
BasePath => '/tmp/cache/http-cache-transparent',
# Verbose => 1,
NoUpdate => 60 * 60,
MaxAge => 15 * 24} ) || die "cache: $!";
my $m1 = WWW::Mechanize->new();
my $m2 = WWW::Mechanize->new();
prun([\&doit, $m1], [\&doit, $m2]) || die(Parallel::Simple::errplus());
prun([\&doit, $m1], [\&doit, $m2]) || die(Parallel::Simple::errplus());
sub doit {
my $m = shift;
$m->back() || $m->get('http://www.google.com');
my %fields = ('f' => 'hello world');
my $r = $m->submit_form(form_number => 1, fields => \%fields);
unless($r->is_success()) {
die $r->status_line();
}
unless($r->content() =~ /<html/i) {
die "oops";
}
print "done\n";
}