1

所以我DBM::Deep用来在不同的分叉进程之间共享数据。我像这样设置我的 DBM::Deep 对象:

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

但是当我运行我的脚本时,我似乎得到了这些错误:

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.

所以除了最后一个错误之外的所有错误都与第 116 行有关,但奇怪的是第 116 行实际上与 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

所以我知道这没什么好做的,但是有没有人遇到这些错误或类似的错误?在如何使用 DBM::Deep 方面我有什么遗漏吗?谢谢!

4

1 回答 1

4

我怀疑问题源于使用 DBM::Deep 对象的副本。尝试在孩子中创建一个新的 DBM::Deep 对象。如果创建子对象时父对象中甚至不存在此类对象,通常会更好。

于 2012-07-06T20:40:32.460 回答