所以我使用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方面,我是否缺少一些东西?谢谢!
答案 0 :(得分:4)
我怀疑问题源于使用DBM :: Deep对象的副本。尝试在子项中创建一个新的DBM :: Deep对象。如果在创建子项时父项中甚至不存在这样的对象,通常会更好。