Question

So I am using DBM::Deep to share data between different forked processes. I set up my DBM::Deep object like this:

my $todo = DBM::Deep->new(
    file      => "urls.db",
    locking   => 1,
    autoflush => 1,
    type      => DBM::Deep->TYPE_HASH
);

But when I run my script I seem to get these errors:

DBM::Deep: Cannot read sector at 673 in get_bucket_list() at new_forked_crawl.pl line 116
DBM::Deep: '30': Don't know what to do with type '' at new_forked_crawl.pl line 116
DBM::Deep: Cannot read sector at 1188 in get_bucket_list() at new_forked_crawl.pl line 116
DBM::Deep: '65536': Don't know what to do with type '' at new_forked_crawl.pl line 116
Can't locate object method "data" via package "DBM::Deep::Sector::File::BucketList" at /usr/lib/perl5/site_perl/5.8.8/DBM/Deep/Engine/File.pm line 160.

So all but the last error have to do with line 116, but what's so bizarre is that line 116 actually has nothing to do with DBM::Deep:

    my $pid = fork();
    if($pid) { #line 116
        push(@forked_children,$pid);
    }
    #child process, do the work, son!
    elsif($pid == 0) {
        process_url($todo->{1}->{'urls_hash'}->{$url_id}{'url'},$url_id);
    } #end $pid else

So I know this isn't a lot to go on, but has anyone run into these errors or some similar to this? Is there something I'm missing in terms of how to use DBM::Deep? Thanks!

Était-ce utile?

La solution

I suspect the problems stem from using a copy of a DBM::Deep object. Try creating a new DBM::Deep object in the child. It usually better if such objects don't even exist in the parent when the child is created.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top